Qt5 How to translate App UI languages
- Adding new language file name in
app.pro
file.
TRANSLATIONS += lg_ch.ts \
lg_en.ts \
lg_new.ts
- Running terminal command:
lupdate app.pro
,to update the ts files. and general lg_new.ts file in the project directory. - Booting the translate tool,run terminal command:
linguist
- Opening ts file. and to translate. when finished translate,don't forget to publish it. then, you will get the
lg_new.qm
file. - Moving all the translated qm files to same directpry under pro path. and add them to Qt Resources file.
- Using the translated file in your program.
void MainWindow::StActionLanguageEnglish()
{
_pTranslator->load(":/lg/language/lg_en.qm");
qApp->installTranslator(_pTranslator);
}
That's All.
版权声明:本博文属于作者原创或从其他地方学习而来的博文,未经许可不得转载.