SlideShare a Scribd company logo
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(); }

More Related Content

What's hot

Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
source{d}
 
L8 file
L8 fileL8 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...
Tsundere Chen
 
Theming Plone with Deliverance
Theming Plone with DeliveranceTheming Plone with Deliverance
Theming Plone with Deliverance
Rok Garbas
 
C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Language
guestaa63aa
 
Life without CPAN
Life without CPANLife without CPAN
Life without CPAN
Bob 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 Go
Digium
 
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
Artem Kovardin
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and Future
Phil Sturgeon
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
Hyejong
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
Raveen Perera
 
Repl internals
Repl internalsRepl internals
Repl internals
MongoDB
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Scheduler
matthewrdale
 
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
 
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
byterock
 
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
Kirk Kimmel
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
Owen 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-pentesting
Steph Cliche
 

What's hot (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
 

Viewers also liked

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

Viewers also liked (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
 

Similar to Qt Translations

XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
Joe 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 PEAR
Stephan Schmidt
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
Goro Fuji
 
Odp
OdpOdp
Php Training
Php TrainingPhp Training
Php Training
adfa
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaga
nohmad
 
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
saniac
 
The JSON Saga
The JSON SagaThe JSON Saga
The JSON Saga
kaven 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 Park
pointstechgeeks
 
Python 3000
Python 3000Python 3000
Python 3000
Bob Chao
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
webhostingguy
 
An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1
Ganesh Samarthyam
 
Php
PhpPhp
John Rowley Notes
John Rowley NotesJohn Rowley Notes
John Rowley Notes
IBAT College
 
Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation Jsonsaga
Ajax 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 memories
TAUS - The Language Data Network
 
Phylogenetics in R
Phylogenetics in RPhylogenetics in R
Phylogenetics in R
schamber
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
Nikhil Jain
 
Easy R
Easy REasy R
Easy R
Ajay Ohri
 

Similar to 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
 

More from Jussi Pohjolainen

Java Web Services
Java Web ServicesJava Web Services
Java Web Services
Jussi Pohjolainen
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
Jussi 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 Animation
Jussi 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 libGDX
Jussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
Jussi Pohjolainen
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Jussi Pohjolainen
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
Jussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
Jussi 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 Gestures
Jussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
Jussi Pohjolainen
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
Jussi 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 Platform
Jussi Pohjolainen
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
Jussi Pohjolainen
 

More from 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
 

Recently uploaded

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 

Recently uploaded (20)

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 

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(); }