SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
Crossing the borders:
         the i18n system




Lorenzo Mancini (lmancini@develer.com)
What is i18n about?
   Embracing a specific national
    environment:
          Language
          Line break behaviour
          Writing direction
          Conventions
   ...without hampering development
(True) Horror Story




We're in 2002, and a big Italian company wants
 to localize their CAD program in Spanish.

             If only it wasn't for...
(True) Horror Story
   Strings were initially hardcoded in Italian,
    English was retrofitted at some point...
   ...with lots of if/else statements
   First try: add another else branch for each
    string in code (...)
   Second try: tool to produce multiple
    codebases – one for each language (...)
   AFAIK still unfinished two years later
All we need is a good workflow
   Developers produce i18n-ready code
          With no codebase pollution
   Translators translate strings
          Iteratively (code and strings can change!)
          No technical knowledge needed
   The framework does the rest
Developers' step 1
   QObject::tr()
       Parse-time: marks strings
       Run-time: translates strings
   Not everything is a QObject...
       QCoreApplication::translate()
       QT_TR_NOOP



                                        6
Developers' step 2
   Use QString for all user visible text
   QString are Unicode strings → transparent
    processing of strings (reg exp, split etc)
   Programmer space strings can still be
    QByteArrays or char *




                                             7
Developers' step 3
   Use QString::arg() for dynamic text
   QString::arg() allows easy argument
    reordering


    void FileCopier::showProgress(int done, int total, const
    QString &currentFile)
    {
         label.setText(tr("%1 of %2 files copied.nCopying: %3")
               .arg(done)
               .arg(total)
               .arg(currentFile));
    }


                                                                   8
Some glue
   Add a TRANSLATIONS entry to .pro
   Run lupdate to extract a .ts file
   Send .ts file to translators
   Run lrelease to produce translated binary
    files
   Set up a QTranslator
   QCoreApplication::installTranslator()



                                                9
Translators' (only) step
   Open .ts file with Linguist
   Fill the missing translations
   There is no step 3


   Developer: “...hey that's not fair!”




                                           10
Some case studies
   Nearing the 2.0 release:
          Parse again with lupdate
          Fill only the missing translations
   Wanting to add a language
          Add that language to TRANSLATIONS
          Run lupdate, translate the new .ts file, lrelease
          This time it's a fairy tale!
   Update language on the fly
          installTranslator sends a changeEvent
                                                               11
Workflow demo




                12
Gotchas
   ::tr assumes latin-1
   What about Designer files?




                                 13
THANKS !
                                Develer S.r.l.
                             Via Mugellese 1/A
                         50013 Campi Bisenzio
                                 Firenze - Italy




Contacts
Mail: info@develer.com
Phone: +39-055-3984627
Fax: +39 178 6003614
http://www.develer.com

Más contenido relacionado

La actualidad más candente

Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
Ken Coenen
 
Clockless design language - ilia greenblat
Clockless design language - ilia greenblatClockless design language - ilia greenblat
Clockless design language - ilia greenblat
chiportal
 

La actualidad más candente (20)

2011.jtr.pbasanta.
2011.jtr.pbasanta.2011.jtr.pbasanta.
2011.jtr.pbasanta.
 
Reactive Qt - Ivan Čukić (Qt World Summit 2015)
Reactive Qt - Ivan Čukić (Qt World Summit 2015)Reactive Qt - Ivan Čukić (Qt World Summit 2015)
Reactive Qt - Ivan Čukić (Qt World Summit 2015)
 
S emb t13-freertos
S emb t13-freertosS emb t13-freertos
S emb t13-freertos
 
lec9_ref.pdf
lec9_ref.pdflec9_ref.pdf
lec9_ref.pdf
 
Yet another introduction to Linux RCU
Yet another introduction to Linux RCUYet another introduction to Linux RCU
Yet another introduction to Linux RCU
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Parallel R
Parallel RParallel R
Parallel R
 
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
 
No Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time JavaNo Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time Java
 
RCU
RCURCU
RCU
 
NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)
 
FreeRTOS Xilinx Vivado: Hello World!
FreeRTOS Xilinx Vivado: Hello World!FreeRTOS Xilinx Vivado: Hello World!
FreeRTOS Xilinx Vivado: Hello World!
 
Extending ns
Extending nsExtending ns
Extending ns
 
Traitement temps réel chez Streamroot - Golang Paris Juin 2016
Traitement temps réel chez Streamroot - Golang Paris Juin 2016Traitement temps réel chez Streamroot - Golang Paris Juin 2016
Traitement temps réel chez Streamroot - Golang Paris Juin 2016
 
Enhancing the region model of RTSJ
Enhancing the region model of RTSJEnhancing the region model of RTSJ
Enhancing the region model of RTSJ
 
2017 10 17_quantum_program_v2
2017 10 17_quantum_program_v22017 10 17_quantum_program_v2
2017 10 17_quantum_program_v2
 
Clockless design language - ilia greenblat
Clockless design language - ilia greenblatClockless design language - ilia greenblat
Clockless design language - ilia greenblat
 
Towards an Integration of the Actor Model in an FRP Language for Small-Scale ...
Towards an Integration of the Actor Model in an FRP Language for Small-Scale ...Towards an Integration of the Actor Model in an FRP Language for Small-Scale ...
Towards an Integration of the Actor Model in an FRP Language for Small-Scale ...
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей Родионов
 

Destacado (7)

Cloud computing, in practice ~ develer workshop
Cloud computing, in practice ~ develer workshopCloud computing, in practice ~ develer workshop
Cloud computing, in practice ~ develer workshop
 
Engagement small
Engagement smallEngagement small
Engagement small
 
BeRTOS Embedded Survey Summary 2011
BeRTOS Embedded Survey Summary 2011BeRTOS Embedded Survey Summary 2011
BeRTOS Embedded Survey Summary 2011
 
Trace32 lo-strumento-piu-completo-per-il-debug-di-un-sistema-linux
Trace32 lo-strumento-piu-completo-per-il-debug-di-un-sistema-linuxTrace32 lo-strumento-piu-completo-per-il-debug-di-un-sistema-linux
Trace32 lo-strumento-piu-completo-per-il-debug-di-un-sistema-linux
 
Farepipi
FarepipiFarepipi
Farepipi
 
Digital to analog convertor
Digital to analog convertorDigital to analog convertor
Digital to analog convertor
 
Sw libero rf
Sw libero rfSw libero rf
Sw libero rf
 

Similar a Crossing the border with Qt: the i18n system

Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 
Linux and Localization Tutorial Paras pradhan Senior Linux ...
Linux and Localization Tutorial Paras pradhan Senior Linux ...Linux and Localization Tutorial Paras pradhan Senior Linux ...
Linux and Localization Tutorial Paras pradhan Senior Linux ...
webhostingguy
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
oscon2007
 
Cmp2412 programming principles
Cmp2412 programming principlesCmp2412 programming principles
Cmp2412 programming principles
NIKANOR THOMAS
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
Atul Shridhar
 

Similar a Crossing the border with Qt: the i18n system (20)

Internazionalizza le tue applicazioni
Internazionalizza le tue applicazioniInternazionalizza le tue applicazioni
Internazionalizza le tue applicazioni
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
Translating Qt Applications
Translating Qt ApplicationsTranslating Qt Applications
Translating Qt Applications
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
 
Linux and Localization Tutorial Paras pradhan Senior Linux ...
Linux and Localization Tutorial Paras pradhan Senior Linux ...Linux and Localization Tutorial Paras pradhan Senior Linux ...
Linux and Localization Tutorial Paras pradhan Senior Linux ...
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
 
Cmp2412 programming principles
Cmp2412 programming principlesCmp2412 programming principles
Cmp2412 programming principles
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...
 
Experience with C++11 in ArangoDB
Experience with C++11 in ArangoDBExperience with C++11 in ArangoDB
Experience with C++11 in ArangoDB
 
Chapter - 1.pptx
Chapter - 1.pptxChapter - 1.pptx
Chapter - 1.pptx
 
python presentation
python presentationpython presentation
python presentation
 
Intermediate Languages
Intermediate LanguagesIntermediate Languages
Intermediate Languages
 
Python Course Basic
Python Course BasicPython Course Basic
Python Course Basic
 
Python lecture 02
Python lecture 02Python lecture 02
Python lecture 02
 
Pharo 2.0: An Exciting Milestone
Pharo 2.0: An Exciting MilestonePharo 2.0: An Exciting Milestone
Pharo 2.0: An Exciting Milestone
 

Más de Develer S.r.l.

Más de Develer S.r.l. (13)

Workshop su Android Kernel Hacking
Workshop su Android Kernel HackingWorkshop su Android Kernel Hacking
Workshop su Android Kernel Hacking
 
Qt roadmap: the future of Qt
Qt roadmap: the future of QtQt roadmap: the future of Qt
Qt roadmap: the future of Qt
 
Qt Quick for dynamic UI development
Qt Quick for dynamic UI developmentQt Quick for dynamic UI development
Qt Quick for dynamic UI development
 
Qt licensing: making the right choice
Qt licensing: making the right choiceQt licensing: making the right choice
Qt licensing: making the right choice
 
Qt Creator: the secret weapon of any c++ programmer
Qt Creator: the secret weapon of any c++ programmerQt Creator: the secret weapon of any c++ programmer
Qt Creator: the secret weapon of any c++ programmer
 
PyQt: rapid application development
PyQt: rapid application developmentPyQt: rapid application development
PyQt: rapid application development
 
Hybrid development using Qt webkit
Hybrid development using Qt webkitHybrid development using Qt webkit
Hybrid development using Qt webkit
 
Smashing the bottleneck: Qt application profiling
Smashing the bottleneck: Qt application profilingSmashing the bottleneck: Qt application profiling
Smashing the bottleneck: Qt application profiling
 
BeRTOS: Sistema Real Time Embedded Free
BeRTOS: Sistema Real Time Embedded FreeBeRTOS: Sistema Real Time Embedded Free
BeRTOS: Sistema Real Time Embedded Free
 
BeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOSBeRTOS: Free Embedded RTOS
BeRTOS: Free Embedded RTOS
 
Develer - Company Profile
Develer - Company ProfileDeveler - Company Profile
Develer - Company Profile
 
Bettersoftware Feedback 2009
Bettersoftware Feedback 2009Bettersoftware Feedback 2009
Bettersoftware Feedback 2009
 
Develer - Qt Embedded - Introduzione
Develer - Qt Embedded - Introduzione Develer - Qt Embedded - Introduzione
Develer - Qt Embedded - Introduzione
 

Último

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Crossing the border with Qt: the i18n system

  • 1. Crossing the borders: the i18n system Lorenzo Mancini (lmancini@develer.com)
  • 2. What is i18n about?  Embracing a specific national environment:  Language  Line break behaviour  Writing direction  Conventions  ...without hampering development
  • 3. (True) Horror Story We're in 2002, and a big Italian company wants to localize their CAD program in Spanish. If only it wasn't for...
  • 4. (True) Horror Story  Strings were initially hardcoded in Italian, English was retrofitted at some point...  ...with lots of if/else statements  First try: add another else branch for each string in code (...)  Second try: tool to produce multiple codebases – one for each language (...)  AFAIK still unfinished two years later
  • 5. All we need is a good workflow  Developers produce i18n-ready code  With no codebase pollution  Translators translate strings  Iteratively (code and strings can change!)  No technical knowledge needed  The framework does the rest
  • 6. Developers' step 1  QObject::tr()  Parse-time: marks strings  Run-time: translates strings  Not everything is a QObject...  QCoreApplication::translate()  QT_TR_NOOP 6
  • 7. Developers' step 2  Use QString for all user visible text  QString are Unicode strings → transparent processing of strings (reg exp, split etc)  Programmer space strings can still be QByteArrays or char * 7
  • 8. Developers' step 3  Use QString::arg() for dynamic text  QString::arg() allows easy argument reordering void FileCopier::showProgress(int done, int total, const QString &currentFile) { label.setText(tr("%1 of %2 files copied.nCopying: %3") .arg(done) .arg(total) .arg(currentFile)); } 8
  • 9. Some glue  Add a TRANSLATIONS entry to .pro  Run lupdate to extract a .ts file  Send .ts file to translators  Run lrelease to produce translated binary files  Set up a QTranslator  QCoreApplication::installTranslator() 9
  • 10. Translators' (only) step  Open .ts file with Linguist  Fill the missing translations  There is no step 3  Developer: “...hey that's not fair!” 10
  • 11. Some case studies  Nearing the 2.0 release:  Parse again with lupdate  Fill only the missing translations  Wanting to add a language  Add that language to TRANSLATIONS  Run lupdate, translate the new .ts file, lrelease  This time it's a fairy tale!  Update language on the fly  installTranslator sends a changeEvent 11
  • 13. Gotchas  ::tr assumes latin-1  What about Designer files? 13
  • 14. THANKS ! Develer S.r.l. Via Mugellese 1/A 50013 Campi Bisenzio Firenze - Italy Contacts Mail: info@develer.com Phone: +39-055-3984627 Fax: +39 178 6003614 http://www.develer.com