Fixed: #1132 Set the LanguageCode when client is creating a client.cfg

This commit is contained in:
kervala 2010-10-16 14:34:09 +02:00
parent 3f3611b92e
commit 2af7301d7d

View file

@ -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 <locale.h>
///////////
// MACRO //
///////////
@ -1895,6 +1898,7 @@ 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)
{
nlerror("CFG::init: Can't create config file '%s'", configFileName.c_str());
@ -1903,7 +1907,25 @@ void CClientConfig::init(const string &configFileName)
{
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<std::string> &languages = CI18N::getLanguageCodes();
// search if current locale is defined in language codes
for(uint i = 0; i < languages.size(); ++i)
{
if (lang == languages[i])
{
fprintf(fp, "LanguageCode = \"%s\";\n", lang.c_str());
break;
}
}
fclose(fp);
}
else