QT5 International

Create Project & Generate .ts

  1. lupdate TestInternational.pro -ts zh_CN.ts

Translate with Linguist

Save & Release to Generate .qm

Add Code to Choose Language

  1. #include "widget.h"
  2. #include <QApplication>
  3.  
  4. #include <QTranslator>
  5.  
  6. #include <QDebug>
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10.     QApplication a(argc, argv);
  11.  
  12.     QTranslator trans;
  13.      if(trans.load(a.applicationDirPath() + "/../../../zh_CN.qm"))
  14.         a.installTranslator(&trans);
  15.  
  16.     Widget w;
  17.     w.show();
  18.  
  19.     return a.exec();
  20. }

The Result