mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r10711) -Fix [Win32]: take default language from current user's locale on Windows (In-)
This commit is contained in:
parent
1c4b953f06
commit
f9411f30c4
@ -1224,6 +1224,8 @@ bool ReadLanguagePack(int lang_index)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Win32 implementation in win32.cpp. */
|
||||
#ifndef WIN32
|
||||
/** Determine the current charset based on the environment
|
||||
* First check some default values, after this one we passed ourselves
|
||||
* and if none exist return the value for $LANG
|
||||
@ -1247,6 +1249,7 @@ const char *GetCurrentLocale(const char *param)
|
||||
|
||||
return getenv("LANG");
|
||||
}
|
||||
#endif /* ifndef WIN32 */
|
||||
|
||||
static int CDECL LanguageCompareFunc(const void *a, const void *b)
|
||||
{
|
||||
|
@ -1264,3 +1264,18 @@ HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags,
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
/** Determine the current user's locale. */
|
||||
const char *GetCurrentLocale(const char *)
|
||||
{
|
||||
char lang[32], country[32];
|
||||
static char retbuf[64];
|
||||
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, lengthof(lang)) == 0 ||
|
||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, country, lengthof(country)) == 0) {
|
||||
/* Unable to retrieve the locale. */
|
||||
return NULL;
|
||||
}
|
||||
/* Format it as 'en_us'. */
|
||||
sprintf(retbuf, "%c%c_%c%c\0", lang[0], lang[1], country[0], country[1]);
|
||||
return retbuf;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user