Linguist support for QML files. (QML UI Language Translation)
-
Hi All,
I want to do language translation for my project the complete GUI is in QML, when i run lupdate on the project the x.ts file dose not contain any of the Context from QML files. Can any one please help me to translate the QML files using Qt Linguist.
Thank You.
-
Hello @Pradeep-P-N,
Does all your text in QML are inside
qsTr ()
or others alternatives ?Did you add your QML files in your
.pro
?
Either via:lupdate_only{ SOURCES = \ file.qml }
or
DISTFILES += \ file.qml
in order for
lupdate
to process the texts to translate.Have a look in Internationalization and Localization with Qt Quick for more informations.
-
Hi @Julien-B
Thank you,
Yes all my QML files contains qsTr(), and in .prolupdate_only { SOURCES += qml/ * .qml \ qml/ * / * .qml \ qml/ * / * / * .qml \ qml/ * / * / * / *.qml \ qml/ * / * / * / * / *.qml }
on lupdate the .ts file generated does not contains all my QML file context.
I have generated .qm file and included in resource qrc.if(language == DE){ qDebug() << "App Is Available In German"; qDebug() << lang_DE->load(":/t1_de.qm", "."); qApp->installTranslator(lang_DE); }else{ qDebug() << "Default Language -- English" << endl; qApp->removeTranslator(lang_DE); }
load is - TRUE
but there is no change in UI, and also how can i load all QML file Context in .ts file.
-
In QML the Context for a traduction is the name of the
.qml
file where it appears.What do you mean exactly when you say there is no Context in
.ts
file ? -
Yes. There is no data related to all QML. I could only see few Qt Context. And only one QML FILE is available in Context of my .ts file.
And even though after updating the .ts file with the single QML context in .ts file
No language change in UI. -
Thank You @Julien-B .
The problem was with loading SOURCES and its solved.