aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-06-26 22:32:51 +0000
committerJohannes Schickel2010-06-26 22:32:51 +0000
commit578cdb2aeb0beff80eb57b4d9fcc504a69593d42 (patch)
tree0e7d20d6411250281d7f0ae095a506978494a224
parent25cb3092f4f2ee84fa26e0f31f81bccb861efe39 (diff)
downloadscummvm-rg350-578cdb2aeb0beff80eb57b4d9fcc504a69593d42.tar.gz
scummvm-rg350-578cdb2aeb0beff80eb57b4d9fcc504a69593d42.tar.bz2
scummvm-rg350-578cdb2aeb0beff80eb57b4d9fcc504a69593d42.zip
Implement support for auto detection of the users preferred locale on Windows.
Note that this might break support for Windows versions older than Win2k, at least according to the MSVC docs GetLocaleInfo is only supported by Win2k+. I added a comment about that though. svn-id: r50348
-rw-r--r--common/translation.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/common/translation.cpp b/common/translation.cpp
index 6ef4be8e3a..c5e41b2ad3 100644
--- a/common/translation.cpp
+++ b/common/translation.cpp
@@ -22,14 +22,21 @@
* $Id$
*/
-#include "translation.h"
-
-DECLARE_SINGLETON(Common::TranslationManager)
-
#ifdef USE_DETECTLANG
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+// winnt.h defines ARRAYSIZE, but we want our own one... - this is needed before including util.h
+#undef ARRAYSIZE
+#else
#include <locale.h>
+#endif // WIN32
#endif
+#include "translation.h"
+
+DECLARE_SINGLETON(Common::TranslationManager)
+
#ifdef USE_TRANSLATION
#include "messages.cpp"
#endif
@@ -43,6 +50,32 @@ namespace Common {
TranslationManager::TranslationManager() {
#ifdef USE_DETECTLANG
+#ifdef WIN32
+ char langName[9];
+ char ctryName[9];
+
+ const LCID languageIdentifier = GetThreadLocale();
+
+ // GetLocalInfo is only supported starting from Windows 2000, according to this:
+ // http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx
+ // On the other hand the locale constants used, seem to exist on Windows 98 too,
+ // check this for that: http://msdn.microsoft.com/en-us/library/dd464799%28v=VS.85%29.aspx
+ //
+ // I am not exactly sure what is the truth now, it might be very well that this breaks
+ // support for systems older than Windows 2000....
+ //
+ // TODO: Check whether this (or ScummVM at all ;-) works on a system with Windows 98 for
+ // example and if it does not and we still want Windows 9x support, we should definitly
+ // think of another solution.
+ if (GetLocaleInfo(languageIdentifier, LOCALE_SISO639LANGNAME, langName, ARRAYSIZE(langName)) != 0 &&
+ GetLocaleInfo(languageIdentifier, LOCALE_SISO3166CTRYNAME, ctryName, ARRAYSIZE(ctryName)) != 0) {
+ _syslang = langName;
+ _syslang += "_";
+ _syslang += ctryName;
+ } else {
+ _syslang = "en_US";
+ }
+#else // WIN32
// Activating current locale settings
const char *locale = setlocale(LC_ALL, "");
@@ -69,6 +102,7 @@ TranslationManager::TranslationManager() {
_syslang = String(locale, length);
}
+#endif // WIN32
#else // USE_DETECTLANG
_syslang = "C";
#endif // USE_DETECTLANG