From b00586df8253a645d4d7a59b68ffa208cb86ee7c Mon Sep 17 00:00:00 2001 From: CeRiAl Date: Sun, 3 Jul 2011 22:34:20 +0200 Subject: MACOSX: Add i18n support for Mac OSX application menu --- backends/platform/sdl/macosx/macosx.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'backends/platform/sdl/macosx/macosx.cpp') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 817f61e864..e263192c82 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -29,9 +29,12 @@ #include "backends/platform/sdl/macosx/macosx.h" #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" +#include "backends/platform/sdl/macosx/appMenu_osx.h" #include "common/archive.h" +#include "common/config-manager.h" #include "common/fs.h" +#include "common/translation.h" #include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef #include "CoreFoundation/CoreFoundation.h" // for CF* stuff @@ -51,6 +54,15 @@ void OSystem_MacOSX::initBackend() { _mixerManager->init(); } +#ifdef USE_TRANSLATION + // We need to initialize the translataion manager here for the following + // call to replaceApplicationMenuItems() work correctly + TransMan.setLanguage(ConfMan.get("gui_language").c_str()); +#endif // USE_TRANSLATION + + // Replace the SDL generated menu items with our own translated ones on Mac-OSX + replaceApplicationMenuItems(); + // Invoke parent implementation of this method OSystem_POSIX::initBackend(); } -- cgit v1.2.3 From 554dda7008d905d47420c495481e796c4059772e Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 13 Jul 2011 09:43:16 -0400 Subject: BACKENDS: Fix compilation on case-sensitive Mac OS X --- backends/platform/sdl/macosx/macosx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/sdl/macosx/macosx.cpp') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index e263192c82..4b3d000d34 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -29,7 +29,7 @@ #include "backends/platform/sdl/macosx/macosx.h" #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" -#include "backends/platform/sdl/macosx/appMenu_osx.h" +#include "backends/platform/sdl/macosx/appmenu_osx.h" #include "common/archive.h" #include "common/config-manager.h" -- cgit v1.2.3 From 5825ccc16865b9c60d2587b31c50d2ebcc9bab67 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 13 Jul 2011 09:47:03 -0400 Subject: BACKENDS: Fix spelling of 'Mac OS X' --- backends/platform/sdl/macosx/macosx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/sdl/macosx/macosx.cpp') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 4b3d000d34..ddfc99570a 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -60,7 +60,7 @@ void OSystem_MacOSX::initBackend() { TransMan.setLanguage(ConfMan.get("gui_language").c_str()); #endif // USE_TRANSLATION - // Replace the SDL generated menu items with our own translated ones on Mac-OSX + // Replace the SDL generated menu items with our own translated ones on Mac OS X replaceApplicationMenuItems(); // Invoke parent implementation of this method -- cgit v1.2.3 From 828f1884b463c49eb39b7f63def0e4bda15d11c6 Mon Sep 17 00:00:00 2001 From: CeRiAl Date: Sun, 3 Jul 2011 23:01:17 +0200 Subject: MACOSX: Add Sparkle support --- backends/platform/sdl/macosx/macosx.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'backends/platform/sdl/macosx/macosx.cpp') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index ddfc99570a..39fd4237ec 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -30,6 +30,7 @@ #include "backends/platform/sdl/macosx/macosx.h" #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" #include "backends/platform/sdl/macosx/appmenu_osx.h" +#include "backends/updates/macosx/macosx-updates.h" #include "common/archive.h" #include "common/config-manager.h" @@ -63,6 +64,11 @@ void OSystem_MacOSX::initBackend() { // Replace the SDL generated menu items with our own translated ones on Mac OS X replaceApplicationMenuItems(); +#if defined(USE_SPARKLE) + // Initialize updates manager + _updateManager = new MacOSXUpdateManager(); +#endif + // Invoke parent implementation of this method OSystem_POSIX::initBackend(); } -- cgit v1.2.3 From 7e7e6069193fead17d0865d252400b6826805ffc Mon Sep 17 00:00:00 2001 From: Oystein Eftevaag Date: Tue, 2 Aug 2011 21:00:57 -0400 Subject: MACOSX: Turned update support off by default, simplified and cleaned the pull request --- backends/platform/sdl/macosx/macosx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/sdl/macosx/macosx.cpp') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 39fd4237ec..d9de4e5e33 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -64,7 +64,7 @@ void OSystem_MacOSX::initBackend() { // Replace the SDL generated menu items with our own translated ones on Mac OS X replaceApplicationMenuItems(); -#if defined(USE_SPARKLE) +#ifdef USE_SPARKLE // Initialize updates manager _updateManager = new MacOSXUpdateManager(); #endif -- cgit v1.2.3 From e3d7606188cfa6896da562bd70541a8aff5561b6 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 3 Oct 2011 23:53:22 +0100 Subject: MACOSX: Detect system preferred language when starting bundle This reimplement getSystemLanguage() for MacOS X because setlocale() only works if the application is started from the terminal. Instead we use CFBundleCopyPreferredLocalizationsFromArray() which requires the translations to be listed in the bundle plist file (this had already been committed). This fixes bug #3394080. --- backends/platform/sdl/macosx/macosx.cpp | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'backends/platform/sdl/macosx/macosx.cpp') 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 -- cgit v1.2.3