Get the locale name for OS X from CF rather than wx

Originally committed to SVN as r6954.
This commit is contained in:
Thomas Goyne 2012-08-18 03:13:24 +00:00
parent f2035d76fc
commit 21841e84a8

View file

@ -81,6 +81,10 @@
#include <libaegisub/exception.h> #include <libaegisub/exception.h>
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#endif
/* *** Public API is implemented here *** */ /* *** Public API is implemented here *** */
// Allocate global lock mutex declared in header // Allocate global lock mutex declared in header
@ -305,6 +309,19 @@ static wxString GetSystemLanguage()
return res; return res;
} }
#elif __APPLE__
static wxString GetSystemLanguage()
{
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringRef localeName = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleIdentifier);
char buf[128];
CFStringGetCString(localeName, buf, sizeof buf, kCFStringEncodingUTF8);
CFRelease(locale);
return wxString::FromUTF8(buf);
}
#else #else
static wxString GetSystemLanguage() static wxString GetSystemLanguage()
{ {