author | Wuzzy <Wuzzy2@mail.ru> |
Sat, 24 Mar 2018 00:26:39 +0100 | |
changeset 13274 | e381f5260b45 |
parent 13273 | 8f579173b161 |
child 13275 | 7ed4ab32f351 |
--- a/QTfrontend/campaign.cpp Fri Mar 23 03:37:07 2018 +0100 +++ b/QTfrontend/campaign.cpp Sat Mar 24 00:26:39 2018 +0100 @@ -88,9 +88,7 @@ // get locale QSettings settings(dataMgr.settingsFileName(), QSettings::IniFormat); - QString loc = settings.value("misc/locale", "").toString(); - if (loc.isEmpty()) - loc = QLocale::system().name(); + QString loc = QLocale().name(); QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt"); // if file is non-existant try with language only if (!QFile::exists(campaignDescFile))
--- a/QTfrontend/main.cpp Fri Mar 23 03:37:07 2018 +0100 +++ b/QTfrontend/main.cpp Sat Mar 24 00:26:39 2018 +0100 @@ -372,21 +372,31 @@ if (cc.isEmpty()) { cc = QLocale::system().name(); + qDebug("Detected system locale: %s", qPrintable(cc)); // Fallback to current input locale if "C" locale is returned if(cc == "C") cc = HWApplication::inputMethod()->locale().name(); } - qDebug("Frontend uses locale: %s", qPrintable(cc)); + else + { + qDebug("Configured frontend locale: %s", qPrintable(cc)); + } + QLocale::setDefault(cc); + QString defaultLocaleName = QLocale().name(); + qDebug("Frontend uses locale: %s", qPrintable(defaultLocaleName)); - // Load locale files into translators - if (!TranslatorHedgewars.load(QString("hedgewars_%1").arg(cc), QString("physfs://Locale"))) - qWarning("Failed to install Hedgewars translation (%s)", qPrintable(cc)); - if (!TranslatorQt.load(QString("qt_%1").arg(cc), QString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)))) - qWarning("Failed to install Qt translation (%s)", qPrintable(cc)); - app.installTranslator(&TranslatorHedgewars); - app.installTranslator(&TranslatorQt); - app.setLayoutDirection(QLocale(cc).textDirection()); + if (defaultLocaleName != "C") + { + // Load locale files into translators + if (!TranslatorHedgewars.load(QLocale(), "hedgewars", "_", QString("physfs://Locale"))) + qWarning("Failed to install Hedgewars translation (%s)", qPrintable(defaultLocaleName)); + if (!TranslatorQt.load(QLocale(), "qt", "_", QString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)))) + qWarning("Failed to install Qt translation (%s)", qPrintable(defaultLocaleName)); + app.installTranslator(&TranslatorHedgewars); + app.installTranslator(&TranslatorQt); + } + app.setLayoutDirection(QLocale().textDirection()); } #ifdef _WIN32
--- a/QTfrontend/model/MapModel.cpp Fri Mar 23 03:37:07 2018 +0100 +++ b/QTfrontend/model/MapModel.cpp Sat Mar 24 00:26:39 2018 +0100 @@ -129,18 +129,19 @@ { // get locale QSettings settings(datamgr.settingsFileName(), QSettings::IniFormat); - QString locale = settings.value("misc/locale", "").toString(); - if (locale.isEmpty()) - locale = QLocale::system().name(); + QString locale = QLocale().name(); QSettings descSettings(QString("physfs://Maps/%1/desc.txt").arg(map), QSettings::IniFormat); descSettings.setIniCodec("UTF-8"); desc = descSettings.value(locale, QString()).toString(); - // If not found, try with lanague-only code + // If not found, try with language-only code if (desc.isEmpty()) { QString localeSimple = locale.remove(QRegExp("_.*$")); desc = descSettings.value(localeSimple, QString()).toString(); + // If still not found, use English + if (desc.isEmpty()) + desc = descSettings.value("en", QString()).toString(); } desc = desc.replace("_n", "\n").replace("_c", ",").replace("__", "_"); }
--- a/QTfrontend/ui/page/pagemain.cpp Fri Mar 23 03:37:07 2018 +0100 +++ b/QTfrontend/ui/page/pagemain.cpp Sat Mar 24 00:26:39 2018 +0100 @@ -166,9 +166,7 @@ QSettings settings(dataMgr.settingsFileName(), QSettings::IniFormat); - QString loc = settings.value("misc/locale", "").toString(); - if (loc.isEmpty()) - loc = QLocale::system().name(); + QString loc = QLocale().name(); QString tipFile = QString("physfs://Locale/tips_" + loc + ".xml");
--- a/QTfrontend/ui/page/pagetraining.cpp Fri Mar 23 03:37:07 2018 +0100 +++ b/QTfrontend/ui/page/pagetraining.cpp Sat Mar 24 00:26:39 2018 +0100 @@ -157,9 +157,7 @@ QSettings settings(dataMgr.settingsFileName(), QSettings::IniFormat); - QString loc = settings.value("misc/locale", "").toString(); - if (loc.isEmpty()) - loc = QLocale::system().name(); + QString loc = QLocale().name(); QString infoFile = QString("physfs://Locale/missions_" + loc + ".txt");