diff --git a/MultiMC.cpp b/MultiMC.cpp
index 619a7e0a..80eddcd1 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -54,8 +54,6 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &data_dir_override)
setOrganizationName("MultiMC");
setApplicationName("MultiMC5");
- initTranslations();
-
setAttribute(Qt::AA_UseHighDpiPixmaps);
// Don't quit on hiding the last window
this->setQuitOnLastWindowClosed(false);
@@ -179,6 +177,9 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &data_dir_override)
// load settings
initGlobalSettings();
+ // load translations
+ initTranslations();
+
// initialize the updater
m_updateChecker.reset(new UpdateChecker());
@@ -281,18 +282,20 @@ MultiMC::~MultiMC()
void MultiMC::initTranslations()
{
+ QLocale locale(m_settings->get("Language").toString());
+ QLocale::setDefault(locale);
+ QLOG_INFO() << "Your language is" << locale.bcp47Name();
m_qt_translator.reset(new QTranslator());
- if (m_qt_translator->load("qt_" + QLocale::system().name(),
+ if (m_qt_translator->load("qt_" + locale.bcp47Name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
{
- std::cout << "Loading Qt Language File for "
- << QLocale::system().name().toLocal8Bit().constData() << "...";
+ QLOG_DEBUG() << "Loading Qt Language File for"
+ << locale.bcp47Name().toLocal8Bit().constData() << "...";
if (!installTranslator(m_qt_translator.get()))
{
- std::cout << " failed.";
+ QLOG_ERROR() << "Loading Qt Language File failed.";
m_qt_translator.reset();
}
- std::cout << std::endl;
}
else
{
@@ -300,17 +303,15 @@ void MultiMC::initTranslations()
}
m_mmc_translator.reset(new QTranslator());
- if (m_mmc_translator->load("mmc_" + QLocale::system().name(),
- QDir("translations").absolutePath()))
+ if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), MMC->root() + "/translations"))
{
- std::cout << "Loading MMC Language File for "
- << QLocale::system().name().toLocal8Bit().constData() << "...";
+ QLOG_DEBUG() << "Loading MMC Language File for"
+ << locale.bcp47Name().toLocal8Bit().constData() << "...";
if (!installTranslator(m_mmc_translator.get()))
{
- std::cout << " failed.";
+ QLOG_ERROR() << "Loading MMC Language File failed.";
m_mmc_translator.reset();
}
- std::cout << std::endl;
}
else
{
@@ -410,6 +411,9 @@ void MultiMC::initGlobalSettings()
// Editors
m_settings->registerSetting("JsonEditor", QString());
+ // Language
+ m_settings->registerSetting("Language", QLocale(QLocale::system().language()).bcp47Name());
+
// Console
m_settings->registerSetting("ShowConsole", true);
m_settings->registerSetting("AutoCloseConsole", true);
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 9362075e..e0e1b82c 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -219,6 +219,9 @@ void SettingsDialog::applySettings(SettingsObject *s)
}
}
+ // Language
+ s->set("Language", ui->languageBox->currentData().toLocale().bcp47Name());
+
// Updates
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
@@ -286,6 +289,19 @@ void SettingsDialog::applySettings(SettingsObject *s)
void SettingsDialog::loadSettings(SettingsObject *s)
{
+ // Language
+ ui->languageBox->clear();
+ ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
+ foreach(const QString & lang,
+ QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
+ {
+ QLocale locale(lang.section(QRegExp("[_\.]"), 1));
+ ui->languageBox->addItem(
+ QLocale::languageToString(locale.language()),
+ locale);
+ }
+ ui->languageBox->setCurrentIndex(ui->languageBox->findData(QLocale(s->get("Language").toString())));
+
// Updates
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
ui->devBuildsCheckBox->setChecked(s->get("UseDevBuilds").toBool());
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index dbc8ca88..c1008c75 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -7,7 +7,7 @@
0
0
526
- 628
+ 701
@@ -40,6 +40,20 @@
General
+ -
+
+
-
+
+
+ Language (needs restart):
+
+
+
+ -
+
+
+
+
-
@@ -644,7 +658,6 @@
- settingsTab
buttonBox
sortLastLaunchedBtn
sortByNameBtn