Hi, I have a very strange problem: my application's gui is partially translated although I translated all strings with Qt Linguist. I'm using the following code to load the qm file.

Qt Code:
  1. QTranslator appTranslator;
  2. QTranslator qtTranslator;
  3. QStringList uiLanguages;
  4. // uiLanguages crashes on Windows with 4.8.0 release builds
  5. #if (QT_VERSION >= 0x040801) || (QT_VERSION >= 0x040800 && !defined(Q_OS_WIN))
  6. uiLanguages = QLocale::system().uiLanguages();
  7. #else
  8. uiLanguages << QLocale::system().name();
  9. #endif
  10.  
  11. const QString &appTrPath = QCoreApplication::applicationDirPath()
  12. + QLatin1String(SHARE_PATH "/translations");
  13.  
  14. foreach (QString locale, uiLanguages) {
  15. #if (QT_VERSION >= 0x050000)
  16. locale = QLocale(locale).name();
  17. #else
  18. locale.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
  19. #endif
  20. if (appTranslator.load(QLatin1String("myapp_") + locale, appTrPath)) {
  21. installTranslator(&appTranslator);
  22.  
  23. const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
  24. const QString &qtTrFile = QLatin1String("qt_") + locale;
  25. // Binary installer puts Qt tr files into creatorTrPath
  26. if (qtTranslator.load(qtTrFile, qtTrPath) || qtTranslator.load(qtTrFile, appTrPath)) {
  27. installTranslator(&qtTranslator);
  28. setProperty("qtc_locale", locale);
  29. }
  30. break;
  31. } else if (locale == QLatin1String("C") /* overrideLanguage == "English" */) {
  32. // use built-in
  33. break;
  34. } else if (locale.startsWith(QLatin1String("en")) /* "English" is built-in */) {
  35. // use built-in
  36. break;
  37. }
  38. }
To copy to clipboard, switch view to plain text mode 

Since some strings are correctly translated I presume that the qm file is loaded. I tryed to remove it and, as expected, no string is translated. I loaded the qm file in a binary editor to check reference to untranslated text and the missing strings are there.

to create the qm files I follow the usual procedure:

lupdate -no-obsolete *.cpp *.ui *.h -ts ../translations/*.ts
(translation with Qt Linguist)
cd ../translations
lrelease *.ts

Any idea how debug the problem?

Thanks