KcFnMi
KcFnMi

Reputation: 6171

How to add translation files to Qt

The following questions focus on the same issue, which is translation some Qt inner Words:

Title:Qt: how to translate the buttons in qmessagebox?

Translations of QMessageBox not work in Qt5.3

Qt Dynamic translation of dialog windows

I searched in here and found (at C:\Qt\Qt5.3.2\Tools\QtCreator\share\qtcreator\translations) there is no translation file for brazil/portuguese.

How can I create and contribute one of this files?

Upvotes: 5

Views: 10877

Answers (2)

emKaroly
emKaroly

Reputation: 796

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

Upvotes: 5

Dacown
Dacown

Reputation: 19

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

Upvotes: 1

Related Questions