Qt/translations
From Attie's Wiki
(Difference between revisions)
(Created page with "==Providing the Translations== First, add each language file to the <code>TRANSLATIONS</code> variable: <source lang="text"> TRANSLATIONS = myApp_en.ts \ myApp_...") |
m |
||
Line 1: | Line 1: | ||
− | ==Providing the | + | ==Indicating what to translate== |
+ | Include QTranslator: | ||
+ | <source lang="cpp"> | ||
+ | #include <QTranslator> | ||
+ | </source> | ||
+ | |||
+ | and wrap any strings with the <code>QT_TR_NOOP()</code> macro, the <code>QT_TRANSLATE_NOOP()</code> macro or using the <code>tr()</code> function of <code>QOBJECT</code>: | ||
+ | <source lang="cpp"> | ||
+ | QString mystr = QString(QT_TR_NOOP("Loading, Please Wait...")); | ||
+ | </source> | ||
+ | <source lang="cpp"> | ||
+ | QString mystr = QString(QT_TRANSLATE_NOOP("Message displayed while the system is loading", "Loading, Please Wait...")); | ||
+ | </source> | ||
+ | |||
+ | ==Providing the translations== | ||
First, add each language file to the <code>TRANSLATIONS</code> variable: | First, add each language file to the <code>TRANSLATIONS</code> variable: | ||
<source lang="text"> | <source lang="text"> |
Revision as of 15:46, 11 June 2012
Indicating what to translate
Include QTranslator:
#include <QTranslator>
and wrap any strings with the QT_TR_NOOP()
macro, the QT_TRANSLATE_NOOP()
macro or using the tr()
function of QOBJECT
:
QString mystr = QString(QT_TR_NOOP("Loading, Please Wait..."));
QString mystr = QString(QT_TRANSLATE_NOOP("Message displayed while the system is loading", "Loading, Please Wait..."));
Providing the translations
First, add each language file to the TRANSLATIONS
variable:
TRANSLATIONS = myApp_en.ts \ myApp_fr.ts
Run lupdate
on the project:
lupdate myApp.pro
Provide the translations:
linguist *.ts
Release the translations:
lrelease myApp.pro