diff options
author | KUDr <kudr@openttd.org> | 2007-07-27 22:19:19 +0000 |
---|---|---|
committer | KUDr <kudr@openttd.org> | 2007-07-27 22:19:19 +0000 |
commit | f9411f30c4e955968e7abdecade3303b5e63bb4c (patch) | |
tree | e75eaf77cb4fd8c8fa42083e7e90ce01cd170772 /src/win32.cpp | |
parent | 1c4b953f0673a483c9d62b56efe8611db1ac5839 (diff) | |
download | openttd-f9411f30c4e955968e7abdecade3303b5e63bb4c.tar.xz |
(svn r10711) -Fix [Win32]: take default language from current user's locale on Windows (In-)
Diffstat (limited to 'src/win32.cpp')
-rw-r--r-- | src/win32.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/win32.cpp b/src/win32.cpp index a734acf59..0580087ca 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -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; +} |