X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftinygettext%2Ffindlocale.cpp;h=f559011c05c883008f2ab66297cdd637ffdd8fcd;hb=fea3446f05e1e7673607b835c269d3e8d1929ab3;hp=04d1fb4b87dc4bf531475523cecd87b1a68a4f3a;hpb=942c209cabe46478566cd71d04b2b66f1267847b;p=supertux.git diff --git a/src/tinygettext/findlocale.cpp b/src/tinygettext/findlocale.cpp index 04d1fb4b8..f559011c0 100644 --- a/src/tinygettext/findlocale.cpp +++ b/src/tinygettext/findlocale.cpp @@ -1,6 +1,6 @@ /* findlocale-0.46.tar.gz from http://icculus.org/~aspirin/findlocale/ - + Copyright (C) 2004 Adam D. Moss (the "Author"). All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,6 +26,7 @@ use or other dealings in this Software without prior written authorization from the Author. */ +#include #include #include @@ -36,6 +37,10 @@ from the Author. #include #endif +#ifdef MACOSX +#include +#endif + #include "findlocale.hpp" static int @@ -469,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 */