summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-23 02:25:49 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-23 02:25:49 +0100
commit295c6e808ab15c8f10326d375c7c4cdd80531e5f (patch)
tree5ffe145745fc4d94151b261b734354c9cc404773 /application/pages
parent7a14b639574fb7139761c7ca4986fa03e99b7366 (diff)
downloadMultiMC-295c6e808ab15c8f10326d375c7c4cdd80531e5f.tar
MultiMC-295c6e808ab15c8f10326d375c7c4cdd80531e5f.tar.gz
MultiMC-295c6e808ab15c8f10326d375c7c4cdd80531e5f.tar.lz
MultiMC-295c6e808ab15c8f10326d375c7c4cdd80531e5f.tar.xz
MultiMC-295c6e808ab15c8f10326d375c7c4cdd80531e5f.zip
NOISSUE fix translation listing in settings and translation loading
It was impossible to select and load translations properly.
Diffstat (limited to 'application/pages')
-rw-r--r--application/pages/global/MultiMCPage.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp
index e9b19ac6..03b0c1be 100644
--- a/application/pages/global/MultiMCPage.cpp
+++ b/application/pages/global/MultiMCPage.cpp
@@ -262,8 +262,7 @@ void MultiMCPage::applySettings()
auto s = MMC->settings();
// Language
- s->set("Language",
- ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
+ s->set("Language", ui->languageBox->itemData(ui->languageBox->currentIndex()).toString());
if (ui->resetNotificationsBtn->isChecked())
{
@@ -352,15 +351,32 @@ void MultiMCPage::loadSettings()
{
auto s = MMC->settings();
// Language
- ui->languageBox->clear();
- ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
- for(const QString & lang: QDir("translations").entryList(QStringList() << "*.qm", QDir::Files))
{
- QLocale locale(lang.section(QRegExp("[_\\.]"), 1));
- ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
+ using LanguageItem = std::pair<QString, QString>;
+ std::vector<LanguageItem> items;
+
+ QLocale english("en");
+ items.push_back(std::make_pair(english.nativeLanguageName(), "en"));
+ for(QString lang: QDir("translations").entryList(QStringList() << "*.qm", QDir::Files))
+ {
+ lang.remove(".qm");
+ lang.remove("mmc_");
+ QLocale locale(lang);
+ QString fullLangName = locale.nativeLanguageName();
+ qDebug() << fullLangName << lang;
+ items.push_back(std::make_pair(fullLangName, lang));
+ }
+ std::sort(items.begin(), items.end(), [](const LanguageItem & a, const LanguageItem & b)
+ {
+ return a.first.localeAwareCompare(b.first) < 0;
+ });
+ ui->languageBox->clear();
+ for(auto & item: items)
+ {
+ ui->languageBox->addItem(item.first, item.second);
+ }
+ ui->languageBox->setCurrentIndex(ui->languageBox->findData(s->get("Language").toString()));
}
- ui->languageBox->setCurrentIndex(
- ui->languageBox->findData(QLocale(s->get("Language").toString())));
// Updates
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());