Commit 956dc60b authored by nanahira's avatar nanahira

detect language on linux

parent f8b0e5d4
......@@ -1113,33 +1113,59 @@ void Game::LoadConfig() {
}
}
fclose(fp);
if(!gameConf.locale || wcslen(gameConf.locale) <= 0) {
unsigned int lcid = 0;
#ifdef _WIN32
if(!gameConf.locale) {
unsigned int lcid = ((unsigned int)GetSystemDefaultLangID()) & 0xff;
lcid = ((unsigned int)GetSystemDefaultLangID()) & 0xff;
#else
char* locale_str = getenv("LANG");
if(locale_str) {
if(strstr(locale_str, "zh"))
lcid = 0x04;
else
if(strstr(locale_str, "en"))
lcid = 0x09;
else
if(strstr(locale_str, "es"))
lcid = 0x0a;
else
if(strstr(locale_str, "ja"))
lcid = 0x11;
else
if(strstr(locale_str, "ko"))
lcid = 0x12;
else
if(strstr(locale_str, "pt"))
lcid = 0x16;
}
#endif
switch(lcid) {
case 0x04: {
myswprintf(mainGame->gameConf.locale, L"%ls", L"zh-CN");
myswprintf(gameConf.locale, L"%ls", L"zh-CN");
break;
}
case 0x09: {
myswprintf(mainGame->gameConf.locale, L"%ls", L"en-US");
myswprintf(gameConf.locale, L"%ls", L"en-US");
break;
}
case 0x0a: {
myswprintf(mainGame->gameConf.locale, L"%ls", L"es-ES");
myswprintf(gameConf.locale, L"%ls", L"es-ES");
break;
}
case 0x11: {
myswprintf(mainGame->gameConf.locale, L"%ls", L"ja-JP");
myswprintf(gameConf.locale, L"%ls", L"ja-JP");
break;
}
case 0x12: {
myswprintf(mainGame->gameConf.locale, L"%ls", L"ko-KR");
myswprintf(gameConf.locale, L"%ls", L"ko-KR");
break;
}
case 0x16: {
myswprintf(gameConf.locale, L"%ls", L"pt-BR");
break;
}
}
}
#endif
}
void Game::SaveConfig() {
FILE* fp = fopen("system.conf", "w");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment