mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: #1132 Set the LanguageCode when client is creating a client.cfg
This commit is contained in:
parent
3f3611b92e
commit
2af7301d7d
1 changed files with 29 additions and 7 deletions
|
@ -24,6 +24,7 @@
|
||||||
// Misc.
|
// Misc.
|
||||||
#include "nel/misc/config_file.h"
|
#include "nel/misc/config_file.h"
|
||||||
#include "nel/misc/bit_mem_stream.h"
|
#include "nel/misc/bit_mem_stream.h"
|
||||||
|
#include "nel/misc/i18n.h"
|
||||||
// Client.
|
// Client.
|
||||||
#include "client_cfg.h"
|
#include "client_cfg.h"
|
||||||
#include "entities.h"
|
#include "entities.h"
|
||||||
|
@ -44,6 +45,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// MACRO //
|
// MACRO //
|
||||||
///////////
|
///////////
|
||||||
|
@ -1895,6 +1898,7 @@ void CClientConfig::init(const string &configFileName)
|
||||||
{
|
{
|
||||||
// create the basic .cfg that link the default one
|
// create the basic .cfg that link the default one
|
||||||
FILE *fp = fopen(configFileName.c_str(), "w");
|
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());
|
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 ());
|
nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.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);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue