From 1f3e4725519c24393ba6bc3bceac1ab162686c1a Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 2 Jun 2012 19:05:44 +0200 Subject: [PATCH] Attempt to fix locale detection on OSX. By Henrik Holst. --- Aquaria/UserSettings.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index 652d06f..9d41677 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -39,6 +39,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif +#ifdef BBGE_BUILD_MACOSX + #include +#endif + void UserSettings::save() { //initInputCodeMap(); @@ -641,9 +645,35 @@ void UserSettings::getSystemLocale() system.locale += ctry; } } +#elif BBGE_BUILD_MACOSX + CFLocaleRef locale = CFLocaleCopyCurrent(); + CFTypeRef type; + CFStringRef buf; + + type = CFLocaleGetValue(locale, kCFLocaleLanguageCode); + + if ((buf = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleLanguageCode, type)) != NULL) + { + system.locale = buf; + CFRelease(buf); + CFRelease(type); + + type = CFLocaleGetValue(locale, kCFLocaleCountryCode); + + if ((buf = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleCountryCode, type)) != NULL) + { + system.locale += "_"; + system.locale += buf; + CFRelease(buf); + } + + CFRelease(type); + } + + CFRelease(locale); #else - // FIXME: Apparently this is not set when starting the game via the UI on OSX. const char *lang = (const char *)getenv("LANG"); + if (lang && *lang) { system.locale = lang;