diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-09-09 01:20:17 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-09-09 01:20:17 +0200 |
commit | ec6215a9456dfa4523afd34198ffa878343f5f59 (patch) | |
tree | 36fa5a8238433ef9567ab1e631d15a180b8fa73d /MultiMC.cpp | |
parent | 3e1cb5798835917bd64f34dc52fa1ca44eb4c7b2 (diff) | |
download | MultiMC-ec6215a9456dfa4523afd34198ffa878343f5f59.tar MultiMC-ec6215a9456dfa4523afd34198ffa878343f5f59.tar.gz MultiMC-ec6215a9456dfa4523afd34198ffa878343f5f59.tar.lz MultiMC-ec6215a9456dfa4523afd34198ffa878343f5f59.tar.xz MultiMC-ec6215a9456dfa4523afd34198ffa878343f5f59.zip |
Fix translation initialization (and loading).
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r-- | MultiMC.cpp | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp index 9cbf4947..b49773a1 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -27,6 +27,8 @@ MultiMC::MultiMC ( int& argc, char** argv ) setOrganizationName("Forkk"); setApplicationName("MultiMC 5"); + initTranslations(); + // Print app header std::cout << "MultiMC 5" << std::endl; std::cout << "(c) 2013 MultiMC Contributors" << std::endl << std::endl; @@ -144,10 +146,64 @@ MultiMC::MultiMC ( int& argc, char** argv ) MultiMC::~MultiMC() { + if(m_mmc_translator) + { + removeTranslator(m_mmc_translator); + delete m_mmc_translator; + m_mmc_translator = nullptr; + } + if(m_qt_translator) + { + removeTranslator(m_qt_translator); + delete m_qt_translator; + m_qt_translator = nullptr; + } delete m_settings; delete m_metacache; } +void MultiMC::initTranslations() +{ + m_qt_translator = new QTranslator(); + if(m_qt_translator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + { + std::cout + << "Loading Qt Language File for " + << QLocale::system().name().toLocal8Bit().constData() + << "..."; + if(!installTranslator(m_qt_translator)) + { + std::cout << " failed."; + } + std::cout << std::endl; + } + else + { + delete m_qt_translator; + m_qt_translator = nullptr; + } + + m_mmc_translator = new QTranslator(); + if(m_mmc_translator->load("mmc_" + QLocale::system().name(), QDir("translations").absolutePath())) + { + std::cout + << "Loading MMC Language File for " + << QLocale::system().name().toLocal8Bit().constData() + << "..."; + if(!installTranslator(m_mmc_translator)) + { + std::cout << " failed."; + } + std::cout << std::endl; + } + else + { + delete m_mmc_translator; + m_mmc_translator = nullptr; + } +} + + void MultiMC::initGlobalSettings() { m_settings = new INISettingsObject("multimc.cfg", this); @@ -226,16 +282,6 @@ int main(int argc, char *argv[]) // initialize Qt MultiMC app(argc, argv); - std::cout << "Loading Language File for " << QLocale::system().name().toLocal8Bit().constData() << "..." << std::endl; - - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&qtTranslator); - - QTranslator mmcTranslator; - mmcTranslator.load("mmc_" + QLocale::system().name()); - app.installTranslator(&mmcTranslator); - // show main window MainWindow mainWin; mainWin.show(); |