Quote Originally Posted by wysota View Post
But do you install the translator? Could you show your code? Which Qt version do you use?
I'm using the prebuilt Qt 4.3.0 package that comes with Frugalware.
Here comes the code :

Qt Code:
  1. void EdyukTranslator::setLanguage(const QString& lang)
  2. {
  3. #ifdef _EDYUK_DEBUG_
  4. qDebug("setting language to : %s", qPrintable(lang));
  5. #endif
  6.  
  7. foreach ( QTranslator *t, translators )
  8. {
  9. QCoreApplication::removeTranslator(t);
  10. delete t;
  11. }
  12.  
  13. translators.clear();
  14.  
  15. QString suff = lang + ".qm";
  16. QDir dir(translationsPath());
  17.  
  18. QTranslator *qt = new QTranslator(this);
  19.  
  20. if ( qt->load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) )
  21. QCoreApplication::installTranslator(qt);
  22. else
  23. delete qt;
  24.  
  25. foreach ( QString s, dir.entryList(QDir::Files | QDir::Readable) )
  26. {
  27. //qDebug("entry : %s", qPrintable(s));
  28.  
  29. if ( !s.endsWith(suff) )
  30. continue;
  31.  
  32. //qDebug("translator found!");
  33.  
  34. QTranslator *t = new QTranslator(this);
  35.  
  36. if ( t->load(dir.filePath(s)) )
  37. {
  38. QCoreApplication::installTranslator(t);
  39. #ifdef _EDYUK_DEBUG_
  40. qDebug("successfuly loaded data from %s", qPrintable(dir.filePath(s)));
  41. #endif
  42. } else {
  43. delete t;
  44. #ifdef _EDYUK_DEBUG_
  45. qDebug("failed to load data from %s", qPrintable(dir.filePath(s)));
  46. #endif
  47. }
  48. }
  49.  
  50. pMenu->setTitle(tr("Language"));
  51.  
  52. sLang = lang;
  53. setValue("last", sLang);
  54.  
  55. emit languageChanged(sLang);
  56.  
  57. QEvent e((QEvent::Type)Edyuk::RunTimeTranslation);
  58. QCoreApplication::sendEvent(qApp, &e);
  59. }
To copy to clipboard, switch view to plain text mode 

Quote Originally Posted by wysota View Post
BTW. You can try loading the .ts file instead of .qm. And what does installTranslator report?
Do you mean that I would not have to generate a .qm from the .ts but just load the .ts as is? Are you sure this would work?