summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKUDr <KUDr@openttd.org>2007-07-27 22:19:19 +0000
committerKUDr <KUDr@openttd.org>2007-07-27 22:19:19 +0000
commit1eda754469b6c132ad24864f5d7d0ba57c33a867 (patch)
treee75eaf77cb4fd8c8fa42083e7e90ce01cd170772
parent260932d8ea8c8e21429be8a8ebe60d1a1255d9db (diff)
downloadopenttd-1eda754469b6c132ad24864f5d7d0ba57c33a867.tar.xz
(svn r10711) -Fix [Win32]: take default language from current user's locale on Windows (In-)
-rw-r--r--src/strings.cpp3
-rw-r--r--src/win32.cpp15
2 files changed, 18 insertions, 0 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 4ea1bc273..51dc504ad 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -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)
{
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;
+}