# HG changeset patch # User Wuzzy # Date 1491405814 -7200 # Node ID 1c3670021559c2999581104c0d6848c4749d1d23 # Parent cb3e785534dadd4b93b0decb9275e340514c0aee Display native language names in language combo box instead of always English diff -r cb3e785534da -r 1c3670021559 QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Tue Apr 04 23:43:19 2017 +0200 +++ b/QTfrontend/ui/page/pageoptions.cpp Wed Apr 05 17:23:34 2017 +0200 @@ -626,12 +626,31 @@ CBLanguage->setMaxVisibleItems(50); groupMisc->layout()->addWidget(CBLanguage, 0, 1); QStringList locs = DataManager::instance().entryList("Locale", QDir::Files, QStringList("hedgewars_*.qm")); + QStringList langnames; CBLanguage->addItem(QComboBox::tr("(System default)"), QString()); for(int i = 0; i < locs.count(); i++) { QString lname = locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"); - QLocale loc(lname); - CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", lname); + QLocale loc = QLocale(lname); + QString entryName; + // If local identifier has underscore, it means the country has been specified + if(lname.contains("_")) + { + // Append country name for disambiguation + // FIXME: These brackets are hardcoded and can't be translated. Luckily, these are rarely used and work with most languages anyway + entryName = loc.nativeLanguageName() + " (" + loc.nativeCountryName() + ")"; + } + else + { + // Usually, we just print the language name + entryName = loc.nativeLanguageName(); + } + // Fallback code: If language name is empty for some reason, print locale identifier. This should normally not happen + if(entryName.isEmpty()) + { + entryName = tr("MISSING LANGUAGE NAME [%1]").arg(lname); + } + CBLanguage->addItem(entryName, lname); } QLabel *restartNoticeLabel = new QLabel(groupMisc);