aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCeRiAl2011-06-13 04:39:38 +0200
committerCeRiAl2011-06-14 22:42:16 +0200
commit2ff4380c55d67668e743edd0a17737a0dc17402e (patch)
tree61d1973a0cafdf427cd69038336a76a699f18ae3
parente826aaab39f02360c5fa8f249ec6b788a903b948 (diff)
downloadscummvm-rg350-2ff4380c55d67668e743edd0a17737a0dc17402e.tar.gz
scummvm-rg350-2ff4380c55d67668e743edd0a17737a0dc17402e.tar.bz2
scummvm-rg350-2ff4380c55d67668e743edd0a17737a0dc17402e.zip
WINCE: Add support for language auto-detection in WinCE
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/platform/wince/wince-sdl.cpp67
-rw-r--r--backends/platform/wince/wince-sdl.h2
-rwxr-xr-xconfigure9
4 files changed, 76 insertions, 4 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index afc6c850d9..fd27c82797 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 3ab9dc8aa4..54fa71cfd2 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 adb63eb936..481956c19a 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 b436a3822d..b012ccc7bd 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