[Scummvm-cvs-logs] SF.net SVN: scummvm:[54480] scummvm/trunk/common/translation.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu Nov 25 19:42:05 CET 2010
Revision: 54480
http://scummvm.svn.sourceforge.net/scummvm/?rev=54480&view=rev
Author: lordhoto
Date: 2010-11-25 18:42:05 +0000 (Thu, 25 Nov 2010)
Log Message:
-----------
COMMON: Adapt translation manager to use the OSystem for language detection.
Modified Paths:
--------------
scummvm/trunk/common/translation.cpp
Modified: scummvm/trunk/common/translation.cpp
===================================================================
--- scummvm/trunk/common/translation.cpp 2010-11-25 18:40:56 UTC (rev 54479)
+++ scummvm/trunk/common/translation.cpp 2010-11-25 18:42:05 UTC (rev 54480)
@@ -36,15 +36,10 @@
#include "common/config-manager.h"
#include "common/file.h"
#include "common/fs.h"
+#include "common/system.h"
DECLARE_SINGLETON(Common::TranslationManager);
-#ifdef USE_DETECTLANG
-#ifndef WIN32
-#include <locale.h>
-#endif // !WIN32
-#endif
-
namespace Common {
bool operator<(const TLanguage &l, const TLanguage &r) {
@@ -58,68 +53,12 @@
TranslationManager::TranslationManager() : _currentLang(-1) {
loadTranslationsInfoDat();
-#ifdef USE_DETECTLANG
-// FIXME: language detection should be done via an OSystem API.
-#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
- // way to determine the locale string for 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, sizeof(langName)) != 0 &&
- GetLocaleInfo(languageIdentifier, LOCALE_SISO3166CTRYNAME, ctryName, sizeof(ctryName)) != 0) {
- _syslang = langName;
- _syslang += "_";
- _syslang += ctryName;
- } else {
+ const char *locale = getLanguageLocale(g_system->getSystemLanguage());
+ if (!locale)
_syslang = "C";
- }
-#else // WIN32
- // Activating current locale settings
- const char *locale = setlocale(LC_ALL, "");
+ else
+ _syslang = locale;
- // Detect the language from the locale
- if (!locale) {
- _syslang = "C";
- } else {
- int length = 0;
-
- // Strip out additional information, like
- // ".UTF-8" or the like. We do this, since
- // our translation languages are usually
- // specified without any charset information.
- for (int i = 0; locale[i]; ++i) {
- // TODO: Check whether "@" should really be checked
- // here.
- if (locale[i] == '.' || locale[i] == ' ' || locale[i] == '@') {
- length = i;
- break;
- }
-
- length = i;
- }
-
- _syslang = String(locale, length);
- }
-#endif // WIN32
-#else // USE_DETECTLANG
- _syslang = "C";
-#endif // USE_DETECTLANG
-
// Set the default language
setLanguage("");
}
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