From 2af7301d7d2991ecb689a1be29b9617aab50ac3a Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 14:34:09 +0200 Subject: [PATCH] Fixed: #1132 Set the LanguageCode when client is creating a client.cfg --- code/ryzom/client/src/client_cfg.cpp | 36 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 172a24817..e1e5d9c7d 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -24,6 +24,7 @@ // Misc. #include "nel/misc/config_file.h" #include "nel/misc/bit_mem_stream.h" +#include "nel/misc/i18n.h" // Client. #include "client_cfg.h" #include "entities.h" @@ -44,6 +45,8 @@ # include "config.h" #endif // HAVE_CONFIG_H +#include + /////////// // MACRO // /////////// @@ -1895,15 +1898,34 @@ void CClientConfig::init(const string &configFileName) { // create the basic .cfg that link the default one FILE *fp = fopen(configFileName.c_str(), "w"); - if (fp == NULL) + + if (fp == NULL) + { + nlerror("CFG::init: Can't create config file '%s'", configFileName.c_str()); + } + else + { + nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ()); + } + + fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.c_str()); + + // get current locale + std::string lang = toLower(std::string(setlocale(LC_CTYPE, ""))); + lang = lang.substr(0, 2); + + const std::vector &languages = CI18N::getLanguageCodes(); + + // search if current locale is defined in language codes + for(uint i = 0; i < languages.size(); ++i) { - nlerror ("CFG::init: Can't create config file '%s'", configFileName.c_str()); + if (lang == languages[i]) + { + fprintf(fp, "LanguageCode = \"%s\";\n", lang.c_str()); + break; + } } - else - { - nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ()); - } - fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.c_str()); + fclose(fp); } else