Qt5 How to translate App UI languages

  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.


posted @ 2017-10-02 13:27  [0]  阅读(320)  评论(0编辑  收藏  举报