Create valid (if empty) "C" locale under macOS
Use [NSLocale systemLocale] instead of trying to create a locale with the name "C" which just fails and doesn't create any NSLocale at all. If nothing else, this makes the behaviour of wxUILocale::GetCurrent() consistent on all platforms as its GetLocaleId() now returns "C" everywhere.
This commit is contained in:
parent
14714856b3
commit
e3146f9ac0
1 changed files with 13 additions and 2 deletions
|
|
@ -131,7 +131,13 @@ wxUILocaleImplCF::Use()
|
|||
wxString
|
||||
wxUILocaleImplCF::GetName() const
|
||||
{
|
||||
return wxCFStringRef::AsString([m_nsloc localeIdentifier]);
|
||||
wxString name = wxCFStringRef::AsString([m_nsloc localeIdentifier]);
|
||||
|
||||
// Check for the special case of the "empty" system locale, see CreateStdC()
|
||||
if ( name.empty() )
|
||||
name = "C";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
wxLocaleIdent
|
||||
|
|
@ -209,7 +215,12 @@ wxUILocaleImplCF::GetLayoutDirection() const
|
|||
/* static */
|
||||
wxUILocaleImpl* wxUILocaleImpl::CreateStdC()
|
||||
{
|
||||
return wxUILocaleImplCF::Create(wxLocaleIdent().Language("C"));
|
||||
// This is an "empty" locale, but it seems to correspond rather well to the
|
||||
// "C" locale under POSIX systems and using localeWithLocaleIdentifier:@"C"
|
||||
// wouldn't be much better as we'd still need a hack for it in GetName()
|
||||
// because the locale names are always converted to lower case, while we
|
||||
// really want to return "C" rather than "c" as the name of this one.
|
||||
return new wxUILocaleImplCF([NSLocale systemLocale]);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue