Cannot internationalization, help
environment: desktop, qtcreator, qt 5.1.1
In a simple test application, I cannot translate English into Chinese using QTranslator.
A simple dialog with a label, initialize label text when dialog loading.
@Dialog::Dialog(QWidget *parent) :
Create ts file and release it as qm file, "--helloworld--!" is translated into Chinese using Linguist tool.
@int main(int argc, char *argv)
QApplication a(argc, argv);
Dialog w; w.show(); return a.exec();
load and installTranslator return true, but "--helloworld--!" is still showed, not translated text. Where is error in my procedure?
maybe you should have a look on
void QLocale::setDefault(const QLocale & locale) [static]
code is correct.
Please make sure that your translation file really contains a translation for "--helloworld--!" and not as your wrote "—helloworld—!"
My fool, double checked Linguist GUI, I mistook "translation comment" as "translation", thanks raven.
Maybe add the event that is given when translation is changed:
void MainWindow::changeEvent(QEvent* event)
if (event->type() == QEvent::LanguageChange)
// retranslate designer form
This will trigger the widgets to update there language. Also, check that the created label you have made is translatable (should be default in designer, but check anyway).
Did you use QtLiquist to translate your file?