[Scummvm-cvs-logs] SF.net SVN: scummvm:[50348] scummvm/trunk/common/translation.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun Jun 27 00:32:51 CEST 2010
Revision: 50348
http://scummvm.svn.sourceforge.net/scummvm/?rev=50348&view=rev
Author: lordhoto
Date: 2010-06-26 22:32:51 +0000 (Sat, 26 Jun 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/common/translation.cpp
Modified: scummvm/trunk/common/translation.cpp
===================================================================
--- scummvm/trunk/common/translation.cpp 2010-06-26 21:57:13 UTC (rev 50347)
+++ scummvm/trunk/common/translation.cpp 2010-06-26 22:32:51 UTC (rev 50348)
@@ -22,14 +22,21 @@
* $Id$
*/
+#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_DETECTLANG
-#include <locale.h>
-#endif
-
#ifdef USE_TRANSLATION
#include "messages.cpp"
#endif
@@ -43,6 +50,32 @@
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 @@
_syslang = String(locale, length);
}
+#endif // WIN32
#else // USE_DETECTLANG
_syslang = "C";
#endif // USE_DETECTLANG
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list