Fix loading of translation files

The QTranslator objects need to be stored as class attributes as
otherwise they are destroyed after the Application constructor is done
and translations won't work.
This commit is contained in:
Martin Kleusberg
2014-05-24 20:01:22 +02:00
parent a6fdb49aa0
commit 51be349c74
2 changed files with 10 additions and 7 deletions

View File

@@ -22,13 +22,13 @@ Application::Application(int& argc, char** argv) :
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
// Enable translation
QTranslator translator;
translator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
installTranslator(&translator);
QTranslator apptranslator;
apptranslator.load("translations/tr_" + QLocale::system().name());
installTranslator(&apptranslator);
// Load translations
m_translatorQt = new QTranslator();
m_translatorQt->load("qt_de"/* + QLocale::system().name()*/, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
installTranslator(m_translatorQt);
m_translatorApp = new QTranslator();
m_translatorApp->load("tr_de", "translations");// + QLocale::system().name());
installTranslator(m_translatorApp);
// Parse command line
QString fileToOpen;