[Scummvm-cvs-logs] scummvm master -> 2ff4380c55d67668e743edd0a17737a0dc17402e

CeRiAl ikhatib at gmail.com
Tue Jun 14 22:44:18 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2ff4380c55 WINCE: Add support for language auto-detection in WinCE


Commit: 2ff4380c55d67668e743edd0a17737a0dc17402e
    https://github.com/scummvm/scummvm/commit/2ff4380c55d67668e743edd0a17737a0dc17402e
Author: CeRiAl (ikhatib at gmail.com)
Date: 2011-06-14T13:42:16-07:00

Commit Message:
WINCE: Add support for language auto-detection in WinCE

Changed paths:
    backends/platform/sdl/sdl.cpp
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince-sdl.h
    configure



diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index afc6c85..fd27c82 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -301,7 +301,7 @@ void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) {
 }
 
 Common::String OSystem_SDL::getSystemLanguage() const {
-#ifdef USE_DETECTLANG
+#if defined(USE_DETECTLANG) && !defined(_WIN32_WCE)
 #ifdef WIN32
 	// We can not use "setlocale" (at least not for MSVC builds), since it
 	// will return locales like: "English_USA.1252", thus we need a special
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index 3ab9dc8..54fa71c 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -578,6 +578,73 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const {
 	t.tm_sec    = systime.wSecond;
 }
 
+Common::String OSystem_WINCE3::getSystemLanguage() const {
+#ifdef USE_DETECTLANG
+	// We can not use "setlocale" (at least not for MSVC builds), since it
+	// will return locales like: "English_USA.1252", thus we need a special
+	// way to determine the locale string for Win32.
+	char langName[9];
+	char ctryName[9];
+	TCHAR langNameW[32];
+	TCHAR ctryNameW[32];
+	int i = 0;
+	bool localeFound = false;
+	Common::String localeName;
+
+	// Really not nice, but the only way to map Windows CE language/country codes to posix NLS names,
+	// because Windows CE doesn't support LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME,
+	// according to this: http://msdn.microsoft.com/en-us/library/aa912934.aspx
+	//
+	// See http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx for a translation table
+	// This table has to be updated manually when new translations are added
+	const char *posixMappingTable[][3] = {
+		{"CAT", "ESP", "ca_ES"},
+		{"CSY", "CZE", "cs_CZ"},
+		{"DAN", "DNK", "da_DA"},
+		{"DEU", "DEU", "de_DE"},
+		{"ESN", "ESP", "es_ES"},
+		{"ESP", "ESP", "es_ES"},
+		{"FRA", "FRA", "fr_FR"},
+		{"HUN", "HUN", "hu_HU"},
+		{"ITA", "ITA", "it_IT"},
+		{"NOR", "NOR", "nb_NO"},
+		{"NON", "NOR", "nn_NO"},
+		{"PLK", "POL", "pl_PL"},
+		{"PTB", "BRA", "pt_BR"},
+		{"RUS", "RUS", "ru_RU"},
+		{"SVE", "SWE", "se_SE"},
+		{"UKR", "UKR", "uk_UA"},
+		{NULL, NULL, NULL}
+	};
+
+	if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, langNameW, sizeof(langNameW)) != 0 &&
+		GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, ctryNameW, sizeof(ctryNameW)) != 0) {
+		WideCharToMultiByte(CP_ACP, 0, langNameW, -1, langName, (wcslen(langNameW) + 1), NULL, NULL);
+		WideCharToMultiByte(CP_ACP, 0, ctryNameW, -1, ctryName, (wcslen(ctryNameW) + 1), NULL, NULL);
+		
+		debug(1, "Trying to find posix locale name for %s_%s", langName, ctryName);
+		while (posixMappingTable[i][0] && !localeFound) {
+			if ( (!strcmp(posixMappingTable[i][0], langName) || !strcmp(posixMappingTable[i][0], "*")) &&
+				 (!strcmp(posixMappingTable[i][1], ctryName) || !strcmp(posixMappingTable[i][0], "*")) ) {
+				localeFound = true;
+				localeName = posixMappingTable[i][2];
+			}
+			i++;
+		}
+		if (!localeFound) warning("No posix locale name found for %s_%s", langName, ctryName);
+	}
+
+	if (localeFound) {
+		debug(1, "Found posix locale name: %s", localeName.c_str());
+		return localeName;
+	} else {
+		return ModularBackend::getSystemLanguage();
+	}
+#else // USE_DETECTLANG
+	return ModularBackend::getSystemLanguage();
+#endif // USE_DETECTLANG
+}
+
 int OSystem_WINCE3::_platformScreenWidth;
 int OSystem_WINCE3::_platformScreenHeight;
 bool OSystem_WINCE3::_isOzone;
diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h
index adb63eb..481956c 100644
--- a/backends/platform/wince/wince-sdl.h
+++ b/backends/platform/wince/wince-sdl.h
@@ -53,6 +53,8 @@ public:
 
 	// Overloaded from SDL backend
 	void quit();
+	virtual Common::String getSystemLanguage() const;
+
 	// Overloaded from OSystem
 	void engineInit();
 	void getTimeAndDate(TimeDate &t) const;
diff --git a/configure b/configure
index b436a38..b012ccc 100755
--- a/configure
+++ b/configure
@@ -2192,6 +2192,7 @@ if test -n "$_host"; then
 			LDFLAGS="$LDFLAGS -Wl,--stack,65536"
 			_tremolo=yes
 			_backend="wince"
+			_detectlang=yes
 			_mt32emu=no
 			_port_mk="backends/platform/wince/wince.mk"
 			;;
@@ -3083,12 +3084,14 @@ if test "$_translation" = no ; then
 else
 	echo_n "yes ("
 
-	cat > $TMPC << EOF
+	if test "$_detectlang" != yes ; then
+		cat > $TMPC << EOF
 #include <locale.h>
 int main(void) { setlocale(LC_ALL, ""); return 0; }
 EOF
-	_detectlang=no
-	cc_check $LDFLAGS $CXXFLAGS && _detectlang=yes
+		_detectlang=no
+		cc_check $LDFLAGS $CXXFLAGS && _detectlang=yes
+	fi
 
 	define_in_config_h_if_yes $_detectlang 'USE_DETECTLANG'
 	if test "$_detectlang" = yes ; then






More information about the Scummvm-git-logs mailing list