[solved] How to translate english to german language during runtime?
-
hello,
I would like to translate all my strings from english to german. I have create a translation file using cmd line as said here link here.lupdate myproject\ qml\ -ts translation\en_En.ts
. Now a file en_EN.ts has been generated in a folder translation. I have opened this file in Qt linguist and i can see all the strings around 138. I have changed the translation file settings from source lang posix to english. These are my final settings:
source language: English country: any country
target language: German country: German
Thenrelease as
it has generated me a fileen_EN.qm
Now, How should I make use of this file in my QML code to translate from english to german ?Also switch back to english.
I am looking for the qml code.
All my strings are defined like thisqsTr("send")
Thanks a lot :) -
@SGaist
Thanks for the quick reply.
lrelease t1_de.ts
after this line it has generated t1_de.qm file. I have just included in pro fileTRANSLATIONS = t1_de.ts
. Should i include "t1._de.ts" in Resources ? where should i include t1_de.qm file ? because it is just mentioned that it is used by the application at runtime. I am wondering how does it happen if i don't include it.
Thanks -
@SGaist
I can see that from qml this function is invoked but not translating. How do i know that it is loading t1_de.ts file ?i mean any debugging technique ?qDebug()<<"selectedLanguage"; if(language == QString("de")) { translator->load("t1_de", "."); qApp->installTranslator(translator); } if(language == QString("en")) { qApp->removeTranslator(translator); } emit languageChanged();