emulate expected setlocale(0,"") behaviour

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2007-12-04 17:49:29 +00:00
parent 5e4b470119
commit 3a12b759c9

View File

@@ -61,6 +61,12 @@ namespace std {}
using namespace std ;
#endif
#if defined(__DARWIN__)
#include "wx/mac/corefoundation/cfref.h"
#include <CoreFoundation/CFLocale.h>
#include "wx/mac/corefoundation/cfstring.h"
#endif
#if wxUSE_WCHAR_T
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n)
{
@@ -153,7 +159,23 @@ char* wxSetlocale(int category, const char *locale)
return NULL;
#else // !__WXWINCE__
#ifdef __WXMAC__
char *rv = NULL ;
if ( locale != NULL && locale[0] == 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, locale);
#else
char *rv = setlocale(category, locale);
#endif
if ( locale != NULL /* setting locale, not querying */ &&
rv /* call was successful */ )
{