Hello!

I'm knocking my head for some hours now trying to understand why my translation mechanism is not working despite the fact that I followed all translation manuals and examples (no to mention that to translate seems a pretty easy task). What happens is that I created the .ts files, translated (parts of it) in Qt Linguist, created the .qm files and added them to the specified folder. Then I call QTranslator etc. in my program and both finding the translator files as well as loading them returns no error - but no translation actually occurs in the application.

Here is (most of) the code so you all may check if I missed something:

Qt Code:
  1. //main.cpp
  2. qint32 main(qint32 argc, char *argv[])
  3. {
  4. QApplication::setGraphicsSystem("raster");
  5.  
  6. //
  7. QApplication app(argc, argv);
  8. app.setApplicationName("RE8000");
  9. app.setApplicationVersion(APP_VERSION);
  10. app.setOrganizationName("XXXX");
  11. app.setOrganizationDomain("http://www.xxxx.com.br/");
  12.  
  13. app.thread()->setPriority(QThread::HighestPriority);
  14.  
  15. if (!setTranslation())
  16. CFG_ED.setProfileLanguage(CFG::Language_English);
  17.  
  18. //Starts creating the widgets
  19. g_mainSplashScreen = new SplashScreen(QPixmap(":/Images/EntraceImage.bmp"), Qt::WindowStaysOnTopHint);
  20. g_mainSplashScreen->setGeometry((QApplication::desktop()->width() - g_mainSplashScreen->pixmap().width())/2,
  21. (QApplication::desktop()->height() - g_mainSplashScreen->height())/2,
  22. g_mainSplashScreen->pixmap().width(),g_mainSplashScreen->height());
  23. }
  24.  
  25. //...
  26. static bool setTranslation()
  27. {
  28. const CFG::AvailableLanguages currLanguage = CFG_ED.profileLanguage();
  29.  
  30. Settings::Profile::ProfileCenterView::setDefaultLocale(currLanguage);
  31.  
  32. if (Q_UNLIKELY(!Settings::Profile::ProfileCenterView::installLanguage(currLanguage)))
  33. {
  34. mLog("An error occured while trying to load the translation file (static bool setTranslation(QApplication&))");
  35.  
  36. return false;
  37. }
  38.  
  39. return true;
  40. }
  41.  
  42. //Other files
  43. void ProfileCenterView::setDefaultLocale(const Config::UserCfgSingletom::AvailableLanguages language) (static)
  44. {
  45. switch (language)
  46. {
  47. case CFG::Language_English: QLocale::setDefault(QLocale(QLocale::English,QLocale::UnitedStates)); break;
  48. case CFG::Language_Espanol: QLocale::setDefault(QLocale(QLocale::Spanish,QLocale::LatinAmericaAndTheCaribbean)); break;
  49. case CFG::Language_PortugueseBR: QLocale::setDefault(QLocale(QLocale::Portuguese,QLocale::Brazil)); break;
  50.  
  51. default: QLocale::setDefault(QLocale::c()); break;
  52. }
  53. }
  54.  
  55. bool ProfileCenterView::installLanguage(const Config::UserCfgSingletom::AvailableLanguages language) (static)
  56. {
  57. if (language == CFG::Language_English)
  58. return true;
  59.  
  60. //
  61. QDir translationDir(DEFAULT_TRANSLATION_PATH);
  62.  
  63. QStringList fileNameList = translationDir.entryList(QStringList("*.qm"),QDir::Files,QDir::Name);
  64.  
  65. if (Q_UNLIKELY(fileNameList.isEmpty()))
  66. {
  67. mDebugS("Error while trying to install translator: no translator files were found (ProfileCenterView::installLanguage))");
  68. mLog("No translation files were found");
  69.  
  70. return false;
  71. }
  72.  
  73. //![] Install selected translation
  74. QTranslator translator;
  75.  
  76. if (Q_UNLIKELY(!translator.load(QLocale(),"re8000","_",DEFAULT_TRANSLATION_PATH,".qm")))
  77. {
  78. mDebugS("Error while trying to install translator: error while loading file (ProfileCenterView::installLanguage)");
  79. mLog("Error when trying to load the translation file");
  80.  
  81. return false;
  82. }
  83.  
  84. qApp->installTranslator(&translator);
  85.  
  86. return true;
  87. }
To copy to clipboard, switch view to plain text mode 

Remember: as I sad, no errors are returned; only the translations don't appear as if I hadn't done any translations to the .ts file (which I did!).


What could be wrong?

I'm glad for any help,

Momergil