- // we have to emulate the behaviour under OS X
- wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
- wxMacCFStringHolder str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
- wxString langFull = str.AsString()+"_";
- str.Assign(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
- langFull += str.AsString();
- rv = setlocale(category, langFull.c_str());
+ locale_t lt = newlocale(LC_ALL_MASK, "", NULL);
+ if ( lt )
+ {
+ rv = (char*) querylocale( LC_ALL_MASK, lt );
+ freelocale(lt);
+ }
+ if ( rv == NULL || rv[0] == 0 || strcmp( rv , "C" ) == 0 || strcmp( rv, "POSIX" ) == 0 )
+ {
+ // we have to emulate the behaviour under OS X
+ wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
+ wxMacCFStringHolder str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
+ wxString langFull = str.AsString()+"_";
+ str.Assign(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
+ langFull += str.AsString();
+ rv = setlocale(category, langFull.c_str());
+ }
+ else
+ {
+ rv = setlocale(category, rv);
+ }