From e491081166c71ce15f8859453595bb47f3526104 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Sun, 28 Jan 2007 10:13:24 +0000 Subject: [PATCH] Added native OS X language pref support to findlocale. SVN-Revision: 4693 --- src/tinygettext/findlocale.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 */ -- 2.11.0