SlideShare uma empresa Scribd logo
1 de 15
Qt Translations Jussi Pohjolainen Tampere University of Applied Sciences
How to Translate? Every string (visible to user) surrounded by tr() QLabel mytext(tr("Hello World!")); Load a translation (.qm) file at startup Using tr() is good practice, even though you don't have translation files yet.. they can be added later!
tr()? tr() function is a static function defined in QObject QObject::tr(..); tr() returns the translation, if not found, it will return original text // if translation is not found,  // "hello" is returned tr("hello")
Example #include <QtGui> int main(int argc, char *argv[]) {     QApplication a(argc, argv);     QLabel mytext(QObject::tr("Hello World!"));     mytext.show();     return a.exec(); }
Loading Translation Files #include <QtGui> int main(int argc, char *argv[]) {     QApplication a(argc, argv);     QTranslator appTranslator;     // QLocale::system().name() => for example, en_US     appTranslator.load("myapp_" + QLocale::system().name(), ".");     a.installTranslator(&appTranslator);     QLabel mytext(QObject::tr("Hello World!"));     mytext.show();     return a.exec(); }
Translating Applications Run lupdate to extract all tr strings from the application's source code. Translate the application using Qt Linguist Run lrelease to generate binary .qm files that the app can load using QTranslator (done automatically)
lupdate i18n-example.pro lrelease i18n-example.pro  appTranslator.load(...);
1. lupdate Modify .pro file to specify language support TRANSLATIONS = myapp_fi.ts                myapp_fr.ts lupdate will generate these xml-based files lupdate –verbose myapp.pro
tb308pohjus-l:i18n-example pohjus$ cat i18n-example.pro SOURCES += main.cpp TRANSLATIONS = i18n-example_fi.ts i18n-example_en_US.ts tb308pohjus-l:i18n-example pohjus$ lupdate -verbose i18n-example.pro Updating 'i18n-example_en_US.ts'...     Found 1 source text(s) (1 new and 0 already existing) Updating 'i18n-example_fi.ts'...     Found 1 source text(s) (1 new and 0 already existing) tb308pohjus-l:i18n-example pohjus$ ls -al total 1624 drwxr-xr-x  9 pohjus  staff     306  8 Hel 09:38 . drwxr-xr-x  9 pohjus  staff     306  8 Hel 09:16 .. -rw-r--r--  1 pohjus  staff    9484  8 Hel 09:35 Makefile drwxr-xr-x  3 pohjus  staff     102  8 Hel 09:18 i18n-example.app -rw-r--r--  1 pohjus  staff      76  8 Hel 09:38 i18n-example.pro -rw-r--r--  1 pohjus  staff     312  8 Hel 09:38 i18n-example_en_US.ts -rw-r--r--  1 pohjus  staff     312  8 Hel 09:38 i18n-example_fi.ts -rw-r--r--  1 pohjus  staff     371  8 Hel 09:25 main.cpp -rw-r--r--  1 pohjus  staff  799096  8 Hel 09:25 main.o tb308pohjus-l:i18n-example pohjus$
i18n-example_fi.ts <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.0" language="fi_FI"> <context>     <name>QObject</name>     <message>         <location filename="main.cpp" line="12"/>         <source>Hello World!</source>         <translation type="unfinished"></translation>     </message> </context> </TS>
2. Translate: i18n-example_fi.ts <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.0" language="fi_FI"> <context>     <name>QObject</name>     <message>         <location filename="main.cpp" line="12"/>         <source>Hello World!</source>         <translation type="unfinished">Terve maailma!</translation>     </message> </context> </TS>
2. Translate using Qt Linguist
3. Run lrelease Generate .ts files to binary (.qm) either 1) Using Qt Linguist File/Release 2) lrelease lrelease -verbose i18n-example.pro
tb308pohjus-l:i18n-example pohjus$ lrelease -verbose i18n-example.pro Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_en_US.qm'...     Generated 1 translation(s) (0 finished and 1 unfinished) Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_fi.qm'...     Generated 1 translation(s) (0 finished and 1 unfinished)     Generated 1 translation(s) (0 finished and 1 unfinished) tb308pohjus-l:i18n-example pohjus$ rm *.qm tb308pohjus-l:i18n-example pohjus$ lrelease -verbose i18n-example.pro Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_en_US.qm'...     Generated 1 translation(s) (0 finished and 1 unfinished) Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_fi.qm'...     Generated 1 translation(s) (0 finished and 1 unfinished)     Generated 1 translation(s) (0 finished and 1 unfinished) tb308pohjus-l:i18n-example pohjus$ ls -al total 1640 drwxr-xr-x  11 pohjus  staff     374  8 Hel 09:59 . drwxr-xr-x   9 pohjus  staff     306  8 Hel 09:16 .. -rw-r--r--   1 pohjus  staff    9484  8 Hel 09:35 Makefile drwxr-xr-x   3 pohjus  staff     102  8 Hel 09:18 i18n-example.app -rw-r--r--   1 pohjus  staff      76  8 Hel 09:38 i18n-example.pro -rw-r--r--   1 pohjus  staff     127  8 Hel 09:59 i18n-example_en_US.qm -rw-r--r--   1 pohjus  staff     335  8 Hel 09:49 i18n-example_en_US.ts -rw-r--r--   1 pohjus  staff     109  8 Hel 09:59 i18n-example_fi.qm -rw-r--r--   1 pohjus  staff     326  8 Hel 09:49 i18n-example_fi.ts -rw-r--r--   1 pohjus  staff     371  8 Hel 09:25 main.cpp -rw-r--r--   1 pohjus  staff  799096  8 Hel 09:25 main.o
Running #include <QtGui> int main(int argc, char *argv[]) {     QApplication a(argc, argv);     QTranslator appTranslator;     // Path is now ../../../ because of OS X app bundle!     appTranslator.load("i18n-example_fi, "../../../");     a.installTranslator(&appTranslator);     QLabel mytext(QObject::tr("Hello World!"));     mytext.show();     return a.exec(); }

Mais conteúdo relacionado

Mais procurados

Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetupsource{d}
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
 
Theming Plone with Deliverance
Theming Plone with DeliveranceTheming Plone with Deliverance
Theming Plone with DeliveranceRok Garbas
 
C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Languageguestaa63aa
 
Life without CPAN
Life without CPANLife without CPAN
Life without CPANBob Ernst
 
C 檔案輸入與輸出
C 檔案輸入與輸出C 檔案輸入與輸出
C 檔案輸入與輸出PingLun Liao
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with GoDigium
 
C-spirit reborn: why Go was bound to be created
C-spirit reborn: why Go was bound to be createdC-spirit reborn: why Go was bound to be created
C-spirit reborn: why Go was bound to be createdArtem Kovardin
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePhil Sturgeon
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency designHyejong
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMRaveen Perera
 
Repl internals
Repl internalsRepl internals
Repl internalsMongoDB
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Schedulermatthewrdale
 
Introduction to the Python Debugger (pdb)
Introduction to the Python Debugger (pdb)Introduction to the Python Debugger (pdb)
Introduction to the Python Debugger (pdb)Raul Cumplido
 
Embed--Basic PERL XS
Embed--Basic PERL XSEmbed--Basic PERL XS
Embed--Basic PERL XSbyterock
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
2009 10-28-peeking-into-pandoras-bochs red-team-pentesting
2009 10-28-peeking-into-pandoras-bochs red-team-pentesting2009 10-28-peeking-into-pandoras-bochs red-team-pentesting
2009 10-28-peeking-into-pandoras-bochs red-team-pentestingSteph Cliche
 

Mais procurados (20)

Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
 
L8 file
L8 fileL8 file
L8 file
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
 
Theming Plone with Deliverance
Theming Plone with DeliveranceTheming Plone with Deliverance
Theming Plone with Deliverance
 
C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Language
 
Life without CPAN
Life without CPANLife without CPAN
Life without CPAN
 
C 檔案輸入與輸出
C 檔案輸入與輸出C 檔案輸入與輸出
C 檔案輸入與輸出
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with Go
 
C-spirit reborn: why Go was bound to be created
C-spirit reborn: why Go was bound to be createdC-spirit reborn: why Go was bound to be created
C-spirit reborn: why Go was bound to be created
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and Future
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
 
Repl internals
Repl internalsRepl internals
Repl internals
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Scheduler
 
Introduction to the Python Debugger (pdb)
Introduction to the Python Debugger (pdb)Introduction to the Python Debugger (pdb)
Introduction to the Python Debugger (pdb)
 
abu.rpc intro
abu.rpc introabu.rpc intro
abu.rpc intro
 
Embed--Basic PERL XS
Embed--Basic PERL XSEmbed--Basic PERL XS
Embed--Basic PERL XS
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
2009 10-28-peeking-into-pandoras-bochs red-team-pentesting
2009 10-28-peeking-into-pandoras-bochs red-team-pentesting2009 10-28-peeking-into-pandoras-bochs red-team-pentesting
2009 10-28-peeking-into-pandoras-bochs red-team-pentesting
 

Destaque

Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 
Android Security, Signing and Publishing
Android Security, Signing and PublishingAndroid Security, Signing and Publishing
Android Security, Signing and PublishingJussi Pohjolainen
 
Android Http Connection and SAX Parsing
Android Http Connection and SAX ParsingAndroid Http Connection and SAX Parsing
Android Http Connection and SAX ParsingJussi Pohjolainen
 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionJussi Pohjolainen
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkJussi Pohjolainen
 
00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.pptJussi Pohjolainen
 
Android Telephony Manager and SMS
Android Telephony Manager and SMSAndroid Telephony Manager and SMS
Android Telephony Manager and SMSJussi Pohjolainen
 
Short Intro to Android Fragments
Short Intro to Android FragmentsShort Intro to Android Fragments
Short Intro to Android FragmentsJussi Pohjolainen
 

Destaque (20)

Building Web Services
Building Web ServicesBuilding Web Services
Building Web Services
 
Responsive Web Site Design
Responsive Web Site DesignResponsive Web Site Design
Responsive Web Site Design
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Android Security, Signing and Publishing
Android Security, Signing and PublishingAndroid Security, Signing and Publishing
Android Security, Signing and Publishing
 
Android Http Connection and SAX Parsing
Android Http Connection and SAX ParsingAndroid Http Connection and SAX Parsing
Android Http Connection and SAX Parsing
 
Android Essential Tools
Android Essential ToolsAndroid Essential Tools
Android Essential Tools
 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth Connection
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation Framework
 
00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
Android Sensors
Android SensorsAndroid Sensors
Android Sensors
 
Android Multimedia Support
Android Multimedia SupportAndroid Multimedia Support
Android Multimedia Support
 
Android Telephony Manager and SMS
Android Telephony Manager and SMSAndroid Telephony Manager and SMS
Android Telephony Manager and SMS
 
Short Intro to Android Fragments
Short Intro to Android FragmentsShort Intro to Android Fragments
Short Intro to Android Fragments
 
Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 

Semelhante a Qt Translations

XML processing with perl
XML processing with perlXML processing with perl
XML processing with perlJoe Jiang
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARStephan Schmidt
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 
Php Training
Php TrainingPhp Training
Php Trainingadfa
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaganohmad
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python scriptsaniac
 
The JSON Saga
The JSON SagaThe JSON Saga
The JSON Sagakaven yan
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
Python 3000
Python 3000Python 3000
Python 3000Bob Chao
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpointwebhostingguy
 
An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1Ganesh Samarthyam
 
Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaAjax Experience 2009
 
TAUS USER CONFERENCE 2009, Normalization of translation memories
TAUS USER CONFERENCE 2009, Normalization of translation memoriesTAUS USER CONFERENCE 2009, Normalization of translation memories
TAUS USER CONFERENCE 2009, Normalization of translation memoriesTAUS - The Language Data Network
 
Phylogenetics in R
Phylogenetics in RPhylogenetics in R
Phylogenetics in Rschamber
 
PHP Presentation
PHP PresentationPHP Presentation
PHP PresentationNikhil Jain
 

Semelhante a Qt Translations (20)

XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEAR
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
Odp
OdpOdp
Odp
 
Php Training
Php TrainingPhp Training
Php Training
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaga
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 
The JSON Saga
The JSON SagaThe JSON Saga
The JSON Saga
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
Python 3000
Python 3000Python 3000
Python 3000
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1
 
Php
PhpPhp
Php
 
John Rowley Notes
John Rowley NotesJohn Rowley Notes
John Rowley Notes
 
Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation Jsonsaga
 
TAUS USER CONFERENCE 2009, Normalization of translation memories
TAUS USER CONFERENCE 2009, Normalization of translation memoriesTAUS USER CONFERENCE 2009, Normalization of translation memories
TAUS USER CONFERENCE 2009, Normalization of translation memories
 
Phylogenetics in R
Phylogenetics in RPhylogenetics in R
Phylogenetics in R
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Easy R
Easy REasy R
Easy R
 

Mais de Jussi Pohjolainen

libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDXJussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformJussi Pohjolainen
 

Mais de Jussi Pohjolainen (20)

Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha Platform
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

Qt Translations

  • 1. Qt Translations Jussi Pohjolainen Tampere University of Applied Sciences
  • 2. How to Translate? Every string (visible to user) surrounded by tr() QLabel mytext(tr("Hello World!")); Load a translation (.qm) file at startup Using tr() is good practice, even though you don't have translation files yet.. they can be added later!
  • 3. tr()? tr() function is a static function defined in QObject QObject::tr(..); tr() returns the translation, if not found, it will return original text // if translation is not found, // "hello" is returned tr("hello")
  • 4. Example #include <QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel mytext(QObject::tr("Hello World!")); mytext.show(); return a.exec(); }
  • 5. Loading Translation Files #include <QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QTranslator appTranslator; // QLocale::system().name() => for example, en_US appTranslator.load("myapp_" + QLocale::system().name(), "."); a.installTranslator(&appTranslator); QLabel mytext(QObject::tr("Hello World!")); mytext.show(); return a.exec(); }
  • 6. Translating Applications Run lupdate to extract all tr strings from the application's source code. Translate the application using Qt Linguist Run lrelease to generate binary .qm files that the app can load using QTranslator (done automatically)
  • 7. lupdate i18n-example.pro lrelease i18n-example.pro appTranslator.load(...);
  • 8. 1. lupdate Modify .pro file to specify language support TRANSLATIONS = myapp_fi.ts myapp_fr.ts lupdate will generate these xml-based files lupdate –verbose myapp.pro
  • 9. tb308pohjus-l:i18n-example pohjus$ cat i18n-example.pro SOURCES += main.cpp TRANSLATIONS = i18n-example_fi.ts i18n-example_en_US.ts tb308pohjus-l:i18n-example pohjus$ lupdate -verbose i18n-example.pro Updating 'i18n-example_en_US.ts'... Found 1 source text(s) (1 new and 0 already existing) Updating 'i18n-example_fi.ts'... Found 1 source text(s) (1 new and 0 already existing) tb308pohjus-l:i18n-example pohjus$ ls -al total 1624 drwxr-xr-x 9 pohjus staff 306 8 Hel 09:38 . drwxr-xr-x 9 pohjus staff 306 8 Hel 09:16 .. -rw-r--r-- 1 pohjus staff 9484 8 Hel 09:35 Makefile drwxr-xr-x 3 pohjus staff 102 8 Hel 09:18 i18n-example.app -rw-r--r-- 1 pohjus staff 76 8 Hel 09:38 i18n-example.pro -rw-r--r-- 1 pohjus staff 312 8 Hel 09:38 i18n-example_en_US.ts -rw-r--r-- 1 pohjus staff 312 8 Hel 09:38 i18n-example_fi.ts -rw-r--r-- 1 pohjus staff 371 8 Hel 09:25 main.cpp -rw-r--r-- 1 pohjus staff 799096 8 Hel 09:25 main.o tb308pohjus-l:i18n-example pohjus$
  • 10. i18n-example_fi.ts <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.0" language="fi_FI"> <context> <name>QObject</name> <message> <location filename="main.cpp" line="12"/> <source>Hello World!</source> <translation type="unfinished"></translation> </message> </context> </TS>
  • 11. 2. Translate: i18n-example_fi.ts <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.0" language="fi_FI"> <context> <name>QObject</name> <message> <location filename="main.cpp" line="12"/> <source>Hello World!</source> <translation type="unfinished">Terve maailma!</translation> </message> </context> </TS>
  • 12. 2. Translate using Qt Linguist
  • 13. 3. Run lrelease Generate .ts files to binary (.qm) either 1) Using Qt Linguist File/Release 2) lrelease lrelease -verbose i18n-example.pro
  • 14. tb308pohjus-l:i18n-example pohjus$ lrelease -verbose i18n-example.pro Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_en_US.qm'... Generated 1 translation(s) (0 finished and 1 unfinished) Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_fi.qm'... Generated 1 translation(s) (0 finished and 1 unfinished) Generated 1 translation(s) (0 finished and 1 unfinished) tb308pohjus-l:i18n-example pohjus$ rm *.qm tb308pohjus-l:i18n-example pohjus$ lrelease -verbose i18n-example.pro Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_en_US.qm'... Generated 1 translation(s) (0 finished and 1 unfinished) Updating '/Users/pohjus/Documents/Kurssit/TAMK Mobiiliohjelmointi 2 (Symbian)/qt/examples/i18n-example/i18n-example_fi.qm'... Generated 1 translation(s) (0 finished and 1 unfinished) Generated 1 translation(s) (0 finished and 1 unfinished) tb308pohjus-l:i18n-example pohjus$ ls -al total 1640 drwxr-xr-x 11 pohjus staff 374 8 Hel 09:59 . drwxr-xr-x 9 pohjus staff 306 8 Hel 09:16 .. -rw-r--r-- 1 pohjus staff 9484 8 Hel 09:35 Makefile drwxr-xr-x 3 pohjus staff 102 8 Hel 09:18 i18n-example.app -rw-r--r-- 1 pohjus staff 76 8 Hel 09:38 i18n-example.pro -rw-r--r-- 1 pohjus staff 127 8 Hel 09:59 i18n-example_en_US.qm -rw-r--r-- 1 pohjus staff 335 8 Hel 09:49 i18n-example_en_US.ts -rw-r--r-- 1 pohjus staff 109 8 Hel 09:59 i18n-example_fi.qm -rw-r--r-- 1 pohjus staff 326 8 Hel 09:49 i18n-example_fi.ts -rw-r--r-- 1 pohjus staff 371 8 Hel 09:25 main.cpp -rw-r--r-- 1 pohjus staff 799096 8 Hel 09:25 main.o
  • 15. Running #include <QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QTranslator appTranslator; // Path is now ../../../ because of OS X app bundle! appTranslator.load("i18n-example_fi, "../../../"); a.installTranslator(&appTranslator); QLabel mytext(QObject::tr("Hello World!")); mytext.show(); return a.exec(); }