aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp47
-rw-r--r--backends/platform/sdl/macosx/macosx.h2
-rw-r--r--backends/platform/sdl/main.cpp2
-rw-r--r--backends/platform/sdl/posix/posix-main.cpp2
4 files changed, 51 insertions, 2 deletions
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index d9de4e5e33..639bd980f6 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -118,4 +118,51 @@ bool OSystem_MacOSX::displayLogFile() {
return err != noErr;
}
+Common::String OSystem_MacOSX::getSystemLanguage() const {
+#if defined(USE_DETECTLANG) && defined(USE_TRANSLATION)
+ CFArrayRef availableLocalizations = CFBundleCopyBundleLocalizations(CFBundleGetMainBundle());
+ if (availableLocalizations) {
+ CFArrayRef preferredLocalizations = CFBundleCopyPreferredLocalizationsFromArray(availableLocalizations);
+ CFRelease(availableLocalizations);
+ if (preferredLocalizations) {
+ CFIndex localizationsSize = CFArrayGetCount(preferredLocalizations);
+ // Since we have a list of sorted preferred localization, I would like here to
+ // check that they are supported by the TranslationManager and take the first
+ // one that is supported. The listed localizations are taken from the Bundle
+ // plist file, so they should all be supported, unless the plist file is not
+ // synchronized with the translations.dat file. So this is not really a big
+ // issue. And because getSystemLanguage() is called from the constructor of
+ // TranslationManager (therefore before the instance pointer is set), calling
+ // TransMan here results in an infinite loop and creation of a lot of TransMan
+ // instances.
+ /*
+ for (CFIndex i = 0 ; i < localizationsSize ; ++i) {
+ CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(preferredLocalizations, i);
+ char buffer[10];
+ CFStringGetCString(language, buffer, 50, kCFStringEncodingASCII);
+ int32 languageId = TransMan.findMatchingLanguage(buffer);
+ if (languageId != -1) {
+ CFRelease(preferredLocalizations);
+ return TransMan.getLangById(languageId);
+ }
+ }
+ */
+ if (localizationsSize > 0) {
+ CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(preferredLocalizations, 0);
+ char buffer[10];
+ CFStringGetCString(language, buffer, 50, kCFStringEncodingASCII);
+ CFRelease(preferredLocalizations);
+ return buffer;
+ }
+ CFRelease(preferredLocalizations);
+ }
+
+ }
+ // Falback to POSIX implementation
+ return OSystem_POSIX::getSystemLanguage();
+#else // USE_DETECTLANG
+ return OSystem_POSIX::getSystemLanguage();
+#endif // USE_DETECTLANG
+}
+
#endif
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 86c70297ec..4837e643b3 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -32,6 +32,8 @@ public:
virtual bool hasFeature(Feature f);
virtual bool displayLogFile();
+
+ virtual Common::String getSystemLanguage() const;
virtual void initBackend();
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp
index 3947d010c4..040028079d 100644
--- a/backends/platform/sdl/main.cpp
+++ b/backends/platform/sdl/main.cpp
@@ -26,7 +26,7 @@
// of this file. The following "#if" ensures that.
#if !defined(POSIX) && \
!defined(WIN32) && \
- !defined(__MAEMO__) && \
+ !defined(MAEMO) && \
!defined(__SYMBIAN32__) && \
!defined(_WIN32_WCE) && \
!defined(__amigaos4__) && \
diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp
index 3bf7a5138a..5f0914e04f 100644
--- a/backends/platform/sdl/posix/posix-main.cpp
+++ b/backends/platform/sdl/posix/posix-main.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3)
+#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3)
#include "backends/platform/sdl/posix/posix.h"
#include "backends/plugins/sdl/sdl-provider.h"