Remove outdated special case for Mac from wxSetlocale()
This function must be used for setting the default CRT locale only and we can't request arbitrary locales support from it under Mac as it doesn't support any kind of mixed locales, such as "en-FR". We do support them in wxUILocale, and calling wxUILocale::UseDefault() from wxLocale::Init(wxLANGUAGE_DEFAULT) actually worked, but then this function failed because wxSetlocale(LC_ALL, "") did not work for such locales. Fix this simply by removing Mac-specific code from this function. This makes wxLocale::Init(wxLANGUAGE_DEFAULT) work as well as it ever can under Mac.
This commit is contained in:
parent
e3146f9ac0
commit
856c0371fa
1 changed files with 0 additions and 27 deletions
|
|
@ -52,13 +52,6 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__DARWIN__)
|
||||
#include "wx/osx/core/cfref.h"
|
||||
#include <CoreFoundation/CFLocale.h>
|
||||
#include "wx/osx/core/cfstring.h"
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
wxDECL_FOR_STRICT_MINGW32(int, vswprintf, (wchar_t*, const wchar_t*, __VALIST))
|
||||
wxDECL_FOR_STRICT_MINGW32(int, _putws, (const wchar_t*))
|
||||
wxDECL_FOR_STRICT_MINGW32(void, _wperror, (const wchar_t*))
|
||||
|
|
@ -125,27 +118,7 @@ WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n)
|
|||
|
||||
char* wxSetlocale(int category, const char *locale)
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
char *rv = nullptr ;
|
||||
if ( locale != nullptr && locale[0] == 0 )
|
||||
{
|
||||
// the attempt to use newlocale(LC_ALL_MASK, "", nullptr);
|
||||
// here in order to deduce the language along the environment vars rules
|
||||
// lead to strange crashes later...
|
||||
|
||||
// we have to emulate the behaviour under OS X
|
||||
wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
|
||||
wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
|
||||
wxString langFull = str.AsString()+"_";
|
||||
str.reset(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 != nullptr /* setting locale, not querying */ &&
|
||||
rv /* call was successful */ )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue