From 1edf71eedc63bd7990387ec8ecd41b4329e9394b Mon Sep 17 00:00:00 2001 From: Syping Date: Mon, 9 Oct 2017 10:31:52 +0200 Subject: [PATCH] english mode fix --- TranslationClass.cpp | 26 +++++++++++++++++++++++--- TranslationClass.h | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/TranslationClass.cpp b/TranslationClass.cpp index 6dc4d7f..de6efc5 100644 --- a/TranslationClass.cpp +++ b/TranslationClass.cpp @@ -69,6 +69,7 @@ void TranslationClass::loadTranslation(QApplication *app) #ifndef GTA5SYNC_QCONF // Classic modable loading method QString externalLanguageStr; bool externalLanguageReady = false; + bool externalEnglishMode = false; bool loadInternalLang = false; bool trLoadSuccess = false; if (isUserLanguageSystem_p()) @@ -115,11 +116,12 @@ void TranslationClass::loadTranslation(QApplication *app) } if (trLoadSuccess) { - if (currentLangIndex != 0) // Don't install the language until we know we not have a better language for the user + if (currentLangIndex != 0 || isEnglishMode) // Don't install the language until we know we not have a better language for the user { #ifdef GTA5SYNC_DEBUG qDebug() << "externalLanguageReady" << currentLanguage; #endif + externalEnglishMode = isEnglishMode; externalLanguageStr = currentLanguage; externalLanguageReady = true; } @@ -157,8 +159,9 @@ void TranslationClass::loadTranslation(QApplication *app) trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator); #ifdef GTA5SYNC_DEBUG qDebug() << "externalLangIndex" << externalLangIndex << "internalLangIndex" << currentLangIndex; + qDebug() << "externalEnglishMode" << externalEnglishMode << "internalEnglishMode" << isEnglishMode; #endif - if (trLoadSuccess && externalLangIndex > currentLangIndex) + if ((trLoadSuccess && externalLangIndex > currentLangIndex) || (trLoadSuccess && externalEnglishMode && !isEnglishMode)) { #ifdef GTA5SYNC_DEBUG qDebug() << "installInternalTranslation"; @@ -180,6 +183,7 @@ void TranslationClass::loadTranslation(QApplication *app) #ifdef GTA5SYNC_DEBUG qDebug() << "installExternalTranslation"; #endif + isEnglishMode = externalEnglishMode; currentLanguage = externalLanguageStr; app->installTranslator(&exAppTranslator); if (loadQtTranslation_p(exLangPath, &exQtTranslator)) @@ -306,6 +310,7 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla #ifdef GTA5SYNC_DEBUG qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"); #endif + isEnglishMode = false; currentLanguage = languageName; currentLangIndex = currentLangCounter; return true; @@ -321,16 +326,28 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla #ifdef GTA5SYNC_DEBUG qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"); #endif + isEnglishMode = false; + currentLanguage = languageName; + currentLangIndex = currentLangCounter; + return true; + } + else if (langList.at(0) == "en") + { +#ifdef GTA5SYNC_DEBUG + qDebug() << "languageEnglishMode index" << currentLangCounter; +#endif + isEnglishMode = true; currentLanguage = languageName; currentLangIndex = currentLangCounter; return true; } } - if (langList.at(0) == "en") + else if (langList.at(0) == "en") { #ifdef GTA5SYNC_DEBUG qDebug() << "languageEnglishMode index" << currentLangCounter; #endif + isEnglishMode = true; currentLanguage = languageName; currentLangIndex = currentLangCounter; return true; @@ -345,10 +362,12 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla { if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm")) { + isEnglishMode = false; #ifdef GTA5SYNC_DEBUG qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"); #endif currentLanguage = languageName; + currentLangIndex = currentLangCounter; return true; } } @@ -505,6 +524,7 @@ void TranslationClass::unloadTranslation(QApplication *app) currentLangIndex = 0; currentLanguage = QString(); QLocale::setDefault(QLocale::c()); + isEnglishMode = false; isLangLoaded = false; } #ifdef _MSC_VER // Fix dumb Microsoft compiler warning diff --git a/TranslationClass.h b/TranslationClass.h index 4ad4242..532be3b 100644 --- a/TranslationClass.h +++ b/TranslationClass.h @@ -53,6 +53,7 @@ private: QString currentLanguage; QString userLanguage; int currentLangIndex; + bool isEnglishMode; bool isLangLoaded; };