qt5 – How to add translation files to Qt

qt5 – How to add translation files to Qt

TL;DR Use Qt Linguist to create translation files.

The whole process of application translation:

  1. At first you have to prepare your app for translation by marking strings which you want to translate: Writing Source Code for Translation
  2. Translate the application with Qt Linguist: Qt Linguist Manual
  3. Load translation files with application: Hello tr() Example or How to create a multi language application

Add translations to the project

At first you have to prepare your app for translation by marking strings which you want to translate:

tr()

In your qmake project file, the following variable TRANSLATIONS has to be added and must contain all language files you want to create initially.

TRANSLATIONS = languages/TranslationExample_en.ts >languages/TranslationExample_de.ts

You will find lupdate and lrelese int the QT Creater at: Extras-> extern -> linguist

By calling lupdate

lupdate -verbose TranslationExample.pro
You create the language files (.ts), which you translate by using the tool Qt >Linguist.
linguist languages/TranslationExample_en.ts languages/TranslationExample_de.ts

After doing this, you call lrelease to create the binary language files (.qm):

lrelease TranslationExample.pro

You will find this manual as a long version :

http://wiki.qt.io/How_to_create_a_multi_language_application

qt5 – How to add translation files to Qt

Leave a Reply

Your email address will not be published.