Qt5 How to translate App UI languages

羊舌诚
2023-12-01
  1. Adding new language file name in app.pro file.
TRANSLATIONS += lg_ch.ts \
                lg_en.ts \
                lg_new.ts
  1. Running terminal command:lupdate app.pro,to update the ts files. and general lg_new.ts file in the project directory.
  2. Booting the translate tool,run terminal command:linguist
  3. Opening ts file. and to translate. when finished translate,don't forget to publish it. then, you will get the lg_new.qm file.
  4. Moving all the translated qm files to same directpry under pro path. and add them to Qt Resources file.
  5. Using the translated file in your program.
void MainWindow::StActionLanguageEnglish()
{
    _pTranslator->load(":/lg/language/lg_en.qm");
    qApp->installTranslator(_pTranslator);
}

That's All.


转载于:https://www.cnblogs.com/zi-xing/p/7406594.html

 类似资料:

相关阅读

相关文章

相关问答