From: Ondřej Hošek Date: Sun, 28 Jan 2007 10:13:24 +0000 (+0000) Subject: Added native OS X language pref support to findlocale. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e491081166c71ce15f8859453595bb47f3526104;p=supertux.git Added native OS X language pref support to findlocale. SVN-Revision: 4693 --- diff --git a/src/tinygettext/findlocale.cpp b/src/tinygettext/findlocale.cpp index d0a391166..42398db37 100644 --- a/src/tinygettext/findlocale.cpp +++ b/src/tinygettext/findlocale.cpp @@ -37,6 +37,10 @@ from the Author. #include #endif +#ifdef MACOSX +#include +#endif + #include "findlocale.hpp" static int @@ -470,6 +474,32 @@ FL_FindLocale(FL_Locale **locale, FL_Domain /*domain*/) { #else /* assume unixoid */ { +#ifdef MACOSX + CFIndex sz; + CFArrayRef languages; + CFStringRef uxstylelangs; + char *uxsl; + + /* get the languages from the user's presets */ + languages = (CFArrayRef)CFPreferencesCopyValue(CFSTR("AppleLanguages"), + kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + + /* join the returned string array into a string separated by colons */ + uxstylelangs = CFStringCreateByCombiningStrings(kCFAllocatorDefault, + languages, CFSTR(":")); + + /* convert this string into a C string */ + sz = CFStringGetLength(uxstylelangs) + 1; + uxsl = (char*)malloc(sz); + CFStringGetCString(uxstylelangs, uxsl, sz, kCFStringEncodingISOLatin1); + + /* add it to the list */ + if (accumulate_locstring(uxsl, rtn)) { + success = FL_CONFIDENT; + } + /* continue the UNIX method */ +#endif /* examples: */ /* sv_SE.ISO_8859-1 */ /* fr_FR.ISO8859-1 */