SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
Translating Qt applications
                                    09/12/09
It does not have to be boring ;-)
Who is Benjamin Poulain at Nokia?
• first support engineer
   – Linux and Mac OS X


• now Webkit developer


• pet projects
   – graphical tablet

   – Cocoa support


                                    2
What do I do after work?

• some hacking
   – web applications

• lots of sport: running, cycling, climbing




                    I am not so good on a snowboard
Why do I work on translations?

• my family do not speak english
  ➡ need for localized software

• work on
  – tutorial in french

  – translation of Qt Creator

  – french community of Qt
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
• Conclusion
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
• Conclusion
Translations increase your user base
 Everybody speaks English. right?
                              Native speaker
                                         Secondary




             Do not understand English


 writing an application is difficult ➜ spread it
What are we gonna do today?

• Why bother?
• Translating your application
   –   Simple application
   –   UI
   –   Source
   –   Integrate the translation

• Tools for translators
• Going further
• Conclusion
Ugly Snake is a mini game in Qt
How do we translate the application?

  Internationalization workflow:

          1) write code ready for translation

          2) extract strings

          3) translate

          4) compile strings
What are we gonna do today?

• Why bother?
• Translating your application
   –   Simple application
   –   UI
   –   Source
   –   Integrate the translation

• Tools for translators
• Going further
• Conclusion
The .ui files are the biggest part

• most strings are in the .ui

• this is what is seen by the user


• good news: work out of the box

   - string extraction

   - translation
What are we gonna do today?

• Why bother?
• Translating your application
   –   Simple application
   –   UI
   –   Source
   –   Integrate the translation

• Tools for translators
• Going further
• Conclusion
Translate the strings with tr()

• QObject::tr() translate a string:
   trayIcon.showMessage("new message", "you have too many mail");


   trayIcon.showMessage(tr("new message"), tr("you have too many mail"));




• works great with QString::arg():
   QString::number(userCount) + "users online";


   tr("%n user(s) online").arg(userCount);
Provide some context for short strings

  What are 1, 2?   tr("The %1 is %2").arg(...);
Provide some context for short strings

  What are 1, 2?        tr("The %1 is %2").arg(...);




  3 ways to add context:
   – luck

   – context in tr():
      tr("The %1 is %2", "The <extension> is <state>").arg(...);



   – comment in code
      //: The <extension> is <state>
      tr("The %1 is %2").arg(...);
How to mark strings for translations?

• tr() returns QString

• QT_TR_NOOP marks for translation

• translated later with tr()

example:
  char *const EDITOR = QT_TR_NOOP("emacs");



  void function() {
      (...)
      QString editor = tr(EDITOR);
      (...)
  }
What are we gonna do today?

• Why bother?
• Translating your application
   –   Simple application
   –   UI
   –   Source
   –   Integrate the translation

• Tools for translators
• Going further
• Conclusion
Applications use a compiled version of the translation


• lrelease compiles .ts in .qm

• .qm is the binary format for release

• fast lookup

• not into the binary
A translator must be installed
• QTranslator

   - translate the strings

   - load the .qm file:
     QTranslator uglySnakeTranslator;
     uglySnakeTranslator.load("uglysnake_" + QLocale::system().name(),
                              QCoreApplication::applicationDirPath());
     app.installTranslator(&uglySnakeTranslator);
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
• Conclusion
There are two kinds of tools for translators

• offline ➜ Qt Linguist

• online ➜ Pootle, ...
Presentation of Linguist
Linguist is great but need to be distributed

• support multiple languages (simultaneously)

• great integration with Qt

• integration with the UI files:

   • errors are spoted imediately

   • full context



but: need to be distributed
Presentation of Pootle
Pootle is great, but offer no integration

• no need to distribute

• easier for amateur



but: no integration (ui files!)
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
  –   “context”
  –   tricky UI
  –   change the language
  –   pitfalls
• Conclusion
One word, multiple concepts

                       noun     édition

          edit
                         verb   éditer



• short text ➜ context
          tr("edit", "verb");
          tr("edit", "noun");


• also in designer
Comments does not disambiguate the strings

• works:
           QString a = tr("edit", "N97");
           QString b = tr("edit", "N900");

• do not work
           //: N97
           QString a = tr("edit");

           //: N900
           QString b = tr("edit");

• why?
Understanding context and disambiguation
                  source      disambiguation


   QPushButton::tr("edit", "verb");


                    context

   QCoreApplication::translate("QPushButton", "edit", "verb");


   QTranslator::translate("QPushButton", "edit", "verb");



    context        source      disambiguation   ➜     result

    QPushButton    edit        verb             ➜     editer

    QPushButton    edit                         ➜
Comments does not disambiguate the strings

• works:
              QString a = tr("edit", "N97");
              QString b = tr("edit", "N900");

• do not work:
              //: N97
              QString a = tr("edit");

              //: N900
              QString b = tr("edit");

• solution:
              //: N97
              QString a = tr("edit", "phoneA");

              //: N900
              QString b = tr("edit", "phoneB");
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
  –   “context”
  –   tricky UI
  –   change the language
  –   pitfalls
• Conclusion
The translation should fit the widgets

• the layouts adapt the widgets




• problems:
   - fixed size
   - phone screen
Some images need a translation

• localize icons, images, etc

• qresource support locale:
         <qresource lang="fr">
           <file>burnIcon.png</file>
         </qresource>
What if you want multiple UI?

• cultural conventions

• phone screens

• right to left interface


✓ Solution: QUiLoader to load the UI

X difficult to maintain

X difficult to document
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
  –   “context”
  –   tricky UI
  –   change the language
  –   pitfalls
• Conclusion
What if the language is changed after the start?

• examples:

   - phone

   - public terminal

   - MS Windows applications
Everything needs a new translation

• LanguageChange event on ::installTranslator()

• QWidget::changeEvent() to catch the event

• UI responds to retranslateUI()

• manual update for the code
        void SettingsPanel::changeEvent(QEvent *e)
        {
            if (e->type() == QEvent::LanguageChange) {
                ui->retranslateUi(this);
                updateSpeedDescription();
            }
            QWidget::changeEvent(e);
        }
When to change the translators?

• LocaleChange event to the active window

➡ install event filter on QApplication

➡ change the translators
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
  –   “context”
  –   tricky UI
  –   change the language
  –   pitfalls
• Conclusion
Translate on painting is not a good strategy
       char languageList[] = { QT_TR_NOOP("english"),
                               QT_TR_NOOP("german") };

       if (language == "english”) {
          ...

       void paintEvent(QEvent *) {
           QString toShow = tr(m_language);
           ...
       }



 list sorted alphabetically:




 ✓ Solution: use classes for identity, not strings
The source might not be in Latin 1

• tr() uses Latin 1 by default
         tr("Qt est génial"); // might fail




✓ Solution 1: use English for the source

✓ Solution 2:

   - QTextCodec::setCodecForTr()

   - CODECFORTR = UTF-8
Mac uses an ordered list of language

• Mac OS X

   - ordered list of languages
                                                      Not accurate
• language selection:
  QTranslator uglySnakeTranslator;
  uglySnakeTranslator.load("uglysnake_" + QLocale::system().name(),
                           QCoreApplication::applicationDirPath());
  app.installTranslator(&uglySnakeTranslator);




✓ Solution: iterate over the languages of core foundation
What are we gonna do today?

• Why bother?
• Translating your application
• Tools for translators
• Going further
• Conclusion
Qt makes translation easy

• Internationalization is important
• Qt already solves the problems
• Minimal changes are needed in the code
   – tr() every string

   – provide context for short strings



➡ think about it when you develop
Translating Qt Applications

Más contenido relacionado

La actualidad más candente

Crossing the border with Qt: the i18n system
Crossing the border with Qt: the i18n systemCrossing the border with Qt: the i18n system
Crossing the border with Qt: the i18n systemDeveler S.r.l.
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kevin Lynch
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Robert Schadek
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ScyllaDB
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and QtICS
 
Maximizing High Performance Applications with CAN Bus
Maximizing High Performance Applications with CAN BusMaximizing High Performance Applications with CAN Bus
Maximizing High Performance Applications with CAN BusJanel Heilbrunn
 
So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?Janel Heilbrunn
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Jimmy Schementi
 
GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)Huy Do
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DMithun Hunsur
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQICS
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUJohn Colvin
 

La actualidad más candente (20)

Crossing the border with Qt: the i18n system
Crossing the border with Qt: the i18n systemCrossing the border with Qt: the i18n system
Crossing the border with Qt: the i18n system
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Qt Quick in depth
Qt Quick in depthQt Quick in depth
Qt Quick in depth
 
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
 
Maximizing High Performance Applications with CAN Bus
Maximizing High Performance Applications with CAN BusMaximizing High Performance Applications with CAN Bus
Maximizing High Performance Applications with CAN Bus
 
So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
04 - Qt Data
04 - Qt Data04 - Qt Data
04 - Qt Data
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
 
GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
Treinamento Qt básico - aula I
Treinamento Qt básico - aula ITreinamento Qt básico - aula I
Treinamento Qt básico - aula I
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
 

Similar a Translating Qt Applications

Nu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comNu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comDay Software
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)lennartkats
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP PerspectiveBarry Jones
 
2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++kinan keshkeh
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.5.3 book - Part 186 of 194The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.5.3 book - Part 186 of 194Mahmoud Samir Fayed
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodeKris Buytaert
 
The Ring programming language version 1.5.4 book - Part 177 of 185
The Ring programming language version 1.5.4 book - Part 177 of 185The Ring programming language version 1.5.4 book - Part 177 of 185
The Ring programming language version 1.5.4 book - Part 177 of 185Mahmoud Samir Fayed
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptxchouguleamruta24
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
 
Internazionalizza le tue applicazioni
Internazionalizza le tue applicazioniInternazionalizza le tue applicazioni
Internazionalizza le tue applicazioniQT-day
 

Similar a Translating Qt Applications (20)

Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Nu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comNu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.com
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
 
2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Return of c++
Return of c++Return of c++
Return of c++
 
Mini-Training: TypeScript
Mini-Training: TypeScriptMini-Training: TypeScript
Mini-Training: TypeScript
 
The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.5.3 book - Part 186 of 194The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.5.3 book - Part 186 of 194
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
The Ring programming language version 1.5.4 book - Part 177 of 185
The Ring programming language version 1.5.4 book - Part 177 of 185The Ring programming language version 1.5.4 book - Part 177 of 185
The Ring programming language version 1.5.4 book - Part 177 of 185
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
Golang
GolangGolang
Golang
 
Golang
GolangGolang
Golang
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
 
Internazionalizza le tue applicazioni
Internazionalizza le tue applicazioniInternazionalizza le tue applicazioni
Internazionalizza le tue applicazioni
 

Más de account inactive

KDE Plasma for Mobile Phones
KDE Plasma for Mobile PhonesKDE Plasma for Mobile Phones
KDE Plasma for Mobile Phonesaccount inactive
 
Shipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for SymbianShipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for Symbianaccount inactive
 
Scripting Your Qt Application
Scripting Your Qt ApplicationScripting Your Qt Application
Scripting Your Qt Applicationaccount inactive
 
Special Effects with Qt Graphics View
Special Effects with Qt Graphics ViewSpecial Effects with Qt Graphics View
Special Effects with Qt Graphics Viewaccount inactive
 
Developments in The Qt WebKit Integration
Developments in The Qt WebKit IntegrationDevelopments in The Qt WebKit Integration
Developments in The Qt WebKit Integrationaccount inactive
 
Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systemsaccount inactive
 
Development with Qt for Windows CE
Development with Qt for Windows CEDevelopment with Qt for Windows CE
Development with Qt for Windows CEaccount inactive
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Frameworkaccount inactive
 
Mobile Development with Qt for Symbian
Mobile Development with Qt for SymbianMobile Development with Qt for Symbian
Mobile Development with Qt for Symbianaccount inactive
 
How to Make Your Qt App Look Native
How to Make Your Qt App Look NativeHow to Make Your Qt App Look Native
How to Make Your Qt App Look Nativeaccount inactive
 
Animation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsAnimation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsaccount inactive
 
Using Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with QtUsing Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with Qtaccount inactive
 
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)account inactive
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qtaccount inactive
 

Más de account inactive (20)

Meet Qt
Meet QtMeet Qt
Meet Qt
 
KDE Plasma for Mobile Phones
KDE Plasma for Mobile PhonesKDE Plasma for Mobile Phones
KDE Plasma for Mobile Phones
 
Shipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for SymbianShipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for Symbian
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Scripting Your Qt Application
Scripting Your Qt ApplicationScripting Your Qt Application
Scripting Your Qt Application
 
Special Effects with Qt Graphics View
Special Effects with Qt Graphics ViewSpecial Effects with Qt Graphics View
Special Effects with Qt Graphics View
 
Developments in The Qt WebKit Integration
Developments in The Qt WebKit IntegrationDevelopments in The Qt WebKit Integration
Developments in The Qt WebKit Integration
 
Qt Kwan-Do
Qt Kwan-DoQt Kwan-Do
Qt Kwan-Do
 
Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systems
 
Development with Qt for Windows CE
Development with Qt for Windows CEDevelopment with Qt for Windows CE
Development with Qt for Windows CE
 
Qt Creator Bootcamp
Qt Creator BootcampQt Creator Bootcamp
Qt Creator Bootcamp
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Framework
 
Mobile Development with Qt for Symbian
Mobile Development with Qt for SymbianMobile Development with Qt for Symbian
Mobile Development with Qt for Symbian
 
How to Make Your Qt App Look Native
How to Make Your Qt App Look NativeHow to Make Your Qt App Look Native
How to Make Your Qt App Look Native
 
Animation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsAnimation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIs
 
Using Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with QtUsing Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with Qt
 
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
 
The Mobility Project
The Mobility ProjectThe Mobility Project
The Mobility Project
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qt
 

Último

Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 

Último (20)

Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 

Translating Qt Applications

  • 1. Translating Qt applications 09/12/09 It does not have to be boring ;-)
  • 2. Who is Benjamin Poulain at Nokia? • first support engineer – Linux and Mac OS X • now Webkit developer • pet projects – graphical tablet – Cocoa support 2
  • 3. What do I do after work? • some hacking – web applications • lots of sport: running, cycling, climbing I am not so good on a snowboard
  • 4. Why do I work on translations? • my family do not speak english ➡ need for localized software • work on – tutorial in french – translation of Qt Creator – french community of Qt
  • 5. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further • Conclusion
  • 6. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further • Conclusion
  • 7. Translations increase your user base Everybody speaks English. right? Native speaker Secondary Do not understand English writing an application is difficult ➜ spread it
  • 8. What are we gonna do today? • Why bother? • Translating your application – Simple application – UI – Source – Integrate the translation • Tools for translators • Going further • Conclusion
  • 9. Ugly Snake is a mini game in Qt
  • 10. How do we translate the application? Internationalization workflow: 1) write code ready for translation 2) extract strings 3) translate 4) compile strings
  • 11. What are we gonna do today? • Why bother? • Translating your application – Simple application – UI – Source – Integrate the translation • Tools for translators • Going further • Conclusion
  • 12. The .ui files are the biggest part • most strings are in the .ui • this is what is seen by the user • good news: work out of the box - string extraction - translation
  • 13. What are we gonna do today? • Why bother? • Translating your application – Simple application – UI – Source – Integrate the translation • Tools for translators • Going further • Conclusion
  • 14. Translate the strings with tr() • QObject::tr() translate a string: trayIcon.showMessage("new message", "you have too many mail"); trayIcon.showMessage(tr("new message"), tr("you have too many mail")); • works great with QString::arg(): QString::number(userCount) + "users online"; tr("%n user(s) online").arg(userCount);
  • 15. Provide some context for short strings What are 1, 2? tr("The %1 is %2").arg(...);
  • 16. Provide some context for short strings What are 1, 2? tr("The %1 is %2").arg(...); 3 ways to add context: – luck – context in tr(): tr("The %1 is %2", "The <extension> is <state>").arg(...); – comment in code //: The <extension> is <state> tr("The %1 is %2").arg(...);
  • 17. How to mark strings for translations? • tr() returns QString • QT_TR_NOOP marks for translation • translated later with tr() example: char *const EDITOR = QT_TR_NOOP("emacs"); void function() { (...) QString editor = tr(EDITOR); (...) }
  • 18. What are we gonna do today? • Why bother? • Translating your application – Simple application – UI – Source – Integrate the translation • Tools for translators • Going further • Conclusion
  • 19. Applications use a compiled version of the translation • lrelease compiles .ts in .qm • .qm is the binary format for release • fast lookup • not into the binary
  • 20. A translator must be installed • QTranslator - translate the strings - load the .qm file: QTranslator uglySnakeTranslator; uglySnakeTranslator.load("uglysnake_" + QLocale::system().name(), QCoreApplication::applicationDirPath()); app.installTranslator(&uglySnakeTranslator);
  • 21. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further • Conclusion
  • 22. There are two kinds of tools for translators • offline ➜ Qt Linguist • online ➜ Pootle, ...
  • 24. Linguist is great but need to be distributed • support multiple languages (simultaneously) • great integration with Qt • integration with the UI files: • errors are spoted imediately • full context but: need to be distributed
  • 26. Pootle is great, but offer no integration • no need to distribute • easier for amateur but: no integration (ui files!)
  • 27. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further – “context” – tricky UI – change the language – pitfalls • Conclusion
  • 28. One word, multiple concepts noun édition edit verb éditer • short text ➜ context tr("edit", "verb"); tr("edit", "noun"); • also in designer
  • 29. Comments does not disambiguate the strings • works: QString a = tr("edit", "N97"); QString b = tr("edit", "N900"); • do not work //: N97 QString a = tr("edit"); //: N900 QString b = tr("edit"); • why?
  • 30. Understanding context and disambiguation source disambiguation QPushButton::tr("edit", "verb"); context QCoreApplication::translate("QPushButton", "edit", "verb"); QTranslator::translate("QPushButton", "edit", "verb"); context source disambiguation ➜ result QPushButton edit verb ➜ editer QPushButton edit ➜
  • 31. Comments does not disambiguate the strings • works: QString a = tr("edit", "N97"); QString b = tr("edit", "N900"); • do not work: //: N97 QString a = tr("edit"); //: N900 QString b = tr("edit"); • solution: //: N97 QString a = tr("edit", "phoneA"); //: N900 QString b = tr("edit", "phoneB");
  • 32. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further – “context” – tricky UI – change the language – pitfalls • Conclusion
  • 33. The translation should fit the widgets • the layouts adapt the widgets • problems: - fixed size - phone screen
  • 34. Some images need a translation • localize icons, images, etc • qresource support locale: <qresource lang="fr"> <file>burnIcon.png</file> </qresource>
  • 35. What if you want multiple UI? • cultural conventions • phone screens • right to left interface ✓ Solution: QUiLoader to load the UI X difficult to maintain X difficult to document
  • 36. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further – “context” – tricky UI – change the language – pitfalls • Conclusion
  • 37. What if the language is changed after the start? • examples: - phone - public terminal - MS Windows applications
  • 38. Everything needs a new translation • LanguageChange event on ::installTranslator() • QWidget::changeEvent() to catch the event • UI responds to retranslateUI() • manual update for the code void SettingsPanel::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { ui->retranslateUi(this); updateSpeedDescription(); } QWidget::changeEvent(e); }
  • 39. When to change the translators? • LocaleChange event to the active window ➡ install event filter on QApplication ➡ change the translators
  • 40. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further – “context” – tricky UI – change the language – pitfalls • Conclusion
  • 41. Translate on painting is not a good strategy char languageList[] = { QT_TR_NOOP("english"), QT_TR_NOOP("german") }; if (language == "english”) { ... void paintEvent(QEvent *) { QString toShow = tr(m_language); ... } list sorted alphabetically: ✓ Solution: use classes for identity, not strings
  • 42. The source might not be in Latin 1 • tr() uses Latin 1 by default tr("Qt est génial"); // might fail ✓ Solution 1: use English for the source ✓ Solution 2: - QTextCodec::setCodecForTr() - CODECFORTR = UTF-8
  • 43. Mac uses an ordered list of language • Mac OS X - ordered list of languages Not accurate • language selection: QTranslator uglySnakeTranslator; uglySnakeTranslator.load("uglysnake_" + QLocale::system().name(), QCoreApplication::applicationDirPath()); app.installTranslator(&uglySnakeTranslator); ✓ Solution: iterate over the languages of core foundation
  • 44. What are we gonna do today? • Why bother? • Translating your application • Tools for translators • Going further • Conclusion
  • 45. Qt makes translation easy • Internationalization is important • Qt already solves the problems • Minimal changes are needed in the code – tr() every string – provide context for short strings ➡ think about it when you develop