From 64617201b029c0df72974e91d3314b5ee0e80971 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 8 Apr 2021 18:05:44 +0100 Subject: [PATCH] GH-3334 Show English variants correctly This will no longer show 'American English' with the statistics of 'British English', yet show the correct translations - and will now display 'British English'. --- api/logic/translations/TranslationsModel.cpp | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/api/logic/translations/TranslationsModel.cpp b/api/logic/translations/TranslationsModel.cpp index adb3fa98..401b64d4 100644 --- a/api/logic/translations/TranslationsModel.cpp +++ b/api/logic/translations/TranslationsModel.cpp @@ -15,7 +15,19 @@ #include "POTranslator.h" -const static QLatin1Literal defaultLangCode("en"); +const static QLatin1Literal defaultLangCode("en_US"); + +static QLocale getLocaleFromKey(const QString &key) { + if(key == "pt") { + return QLocale("pt_PT"); + } + else if (key == "en") { + return QLocale("en_GB"); + } + else { + return QLocale(key); + } +} enum class FileType { @@ -33,12 +45,7 @@ struct Language Language(const QString & _key) { key = _key; - if(key == "pt") { - locale = QLocale("pt_PT"); - } - else { - locale = QLocale(key); - } + locale = getLocaleFromKey(key); updated = (key == defaultLangCode); } @@ -452,7 +459,7 @@ bool TranslationsModel::selectLanguage(QString key) * In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created. * This function is not reentrant. */ - QLocale locale(langCode); + QLocale locale = getLocaleFromKey(langCode); QLocale::setDefault(locale); // if it's the default UI language, finish