/*
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
from the Author.
*/
+#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <winnt.h>
#endif
+#ifdef MACOSX
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
#include "findlocale.hpp"
static int
#endif
static void
-canonise_fl(FL_Locale *l) {
+canonize_fl(FL_Locale *l) {
/* this function fixes some common locale-specifying mistakes */
/* en_UK -> en_GB */
if (l->lang && 0 == strcmp(l->lang, "en")) {
#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 */
#endif
if (success != FL_FAILED) {
- canonise_fl(rtn);
+ canonize_fl(rtn);
}
*locale = rtn;