WINCE: Add support for language auto-detection in WinCE
This commit is contained in:
parent
e826aaab39
commit
2ff4380c55
4 changed files with 76 additions and 4 deletions
|
@ -301,7 +301,7 @@ void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String OSystem_SDL::getSystemLanguage() const {
|
Common::String OSystem_SDL::getSystemLanguage() const {
|
||||||
#ifdef USE_DETECTLANG
|
#if defined(USE_DETECTLANG) && !defined(_WIN32_WCE)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// We can not use "setlocale" (at least not for MSVC builds), since it
|
// 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
|
// will return locales like: "English_USA.1252", thus we need a special
|
||||||
|
|
|
@ -578,6 +578,73 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const {
|
||||||
t.tm_sec = systime.wSecond;
|
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::_platformScreenWidth;
|
||||||
int OSystem_WINCE3::_platformScreenHeight;
|
int OSystem_WINCE3::_platformScreenHeight;
|
||||||
bool OSystem_WINCE3::_isOzone;
|
bool OSystem_WINCE3::_isOzone;
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
|
|
||||||
// Overloaded from SDL backend
|
// Overloaded from SDL backend
|
||||||
void quit();
|
void quit();
|
||||||
|
virtual Common::String getSystemLanguage() const;
|
||||||
|
|
||||||
// Overloaded from OSystem
|
// Overloaded from OSystem
|
||||||
void engineInit();
|
void engineInit();
|
||||||
void getTimeAndDate(TimeDate &t) const;
|
void getTimeAndDate(TimeDate &t) const;
|
||||||
|
|
9
configure
vendored
9
configure
vendored
|
@ -2192,6 +2192,7 @@ if test -n "$_host"; then
|
||||||
LDFLAGS="$LDFLAGS -Wl,--stack,65536"
|
LDFLAGS="$LDFLAGS -Wl,--stack,65536"
|
||||||
_tremolo=yes
|
_tremolo=yes
|
||||||
_backend="wince"
|
_backend="wince"
|
||||||
|
_detectlang=yes
|
||||||
_mt32emu=no
|
_mt32emu=no
|
||||||
_port_mk="backends/platform/wince/wince.mk"
|
_port_mk="backends/platform/wince/wince.mk"
|
||||||
;;
|
;;
|
||||||
|
@ -3083,12 +3084,14 @@ if test "$_translation" = no ; then
|
||||||
else
|
else
|
||||||
echo_n "yes ("
|
echo_n "yes ("
|
||||||
|
|
||||||
cat > $TMPC << EOF
|
if test "$_detectlang" != yes ; then
|
||||||
|
cat > $TMPC << EOF
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
int main(void) { setlocale(LC_ALL, ""); return 0; }
|
int main(void) { setlocale(LC_ALL, ""); return 0; }
|
||||||
EOF
|
EOF
|
||||||
_detectlang=no
|
_detectlang=no
|
||||||
cc_check $LDFLAGS $CXXFLAGS && _detectlang=yes
|
cc_check $LDFLAGS $CXXFLAGS && _detectlang=yes
|
||||||
|
fi
|
||||||
|
|
||||||
define_in_config_h_if_yes $_detectlang 'USE_DETECTLANG'
|
define_in_config_h_if_yes $_detectlang 'USE_DETECTLANG'
|
||||||
if test "$_detectlang" = yes ; then
|
if test "$_detectlang" = yes ; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue