From 63b58b0c8417a7dc6352e4f290b3d55279f6e087 Mon Sep 17 00:00:00 2001 From: Inky Date: Fri, 24 May 2019 03:36:21 +0300 Subject: [PATCH] Changed: unsupported language code default fallback --HG-- branch : compatibility-develop --- code/nel/src/misc/i18n.cpp | 8 ++++---- code/ryzom/client/src/client_cfg.cpp | 29 ++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 3dc3f4859..1a1db0f00 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -58,14 +58,14 @@ void CI18N::initLanguages() _LanguageCodes.push_back("en"); _LanguageCodes.push_back("fr"); _LanguageCodes.push_back("de"); -// _LanguageCodes.push_back("ru"); -// _LanguageCodes.push_back("es"); + _LanguageCodes.push_back("ru"); + _LanguageCodes.push_back("es"); _LanguageNames.push_back(ucstring("English")); _LanguageNames.push_back(ucstring("French")); _LanguageNames.push_back(ucstring("German")); -// _LanguageNames.push_back(ucstring("Russian")); -// _LanguageNames.push_back(ucstring("Spanish")); + _LanguageNames.push_back(ucstring("Russian")); + _LanguageNames.push_back(ucstring("Spanish")); _LanguagesNamesLoaded = true; } diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 3839952b5..1e6bcefe3 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -2019,30 +2019,43 @@ void CClientConfig::init(const string &configFileName) // now we can continue loading and parsing the config file - // if the config file will be modified, it calls automatically the function setValuesOnFileChange() ClientCfg.ConfigFile.setCallback (CClientConfig::setValuesOnFileChange); // load the config files ClientCfg.ConfigFile.load (configFileName); + CConfigFile::CVar *pCV; + // check language code is supported + pCV = ClientCfg.ConfigFile.getVarPtr("LanguageCode"); + if (pCV) + { + std::string lang = pCV->asString(); + if (!CI18N::isLanguageCodeSupported(lang)) + { + nlinfo("Unsupported language code \"%s\" fallback on default", lang.c_str()); + // fallback to default language + ClientCfg.LanguageCode = CI18N::getSystemLanguageCode(); + // update ConfigFile variable + pCV->setAsString(ClientCfg.LanguageCode); + ClientCfg.ConfigFile.save(); + } + } // update the ConfigFile variable in the config file - CConfigFile::CVar *varPtr = ClientCfg.ConfigFile.getVarPtr ("ClientVersion"); - if (varPtr) + pCV = ClientCfg.ConfigFile.getVarPtr("ClientVersion"); + if (pCV) { - string str = varPtr->asString (); + std::string str = pCV->asString (); if (str != getVersion() && ClientCfg.SaveConfig) { nlinfo ("Update and save the ClientVersion variable in config file %s -> %s", str.c_str(), getVersion().c_str()); - varPtr->setAsString (getVersion()); - ClientCfg.ConfigFile.save (); + pCV->setAsString(getVersion()); + ClientCfg.ConfigFile.save(); } } else - { nlwarning ("There's no ClientVersion variable in the config file!"); - } }// init //