Use wxLocaleIdent in Unix wxLocale and wxUILocale code

No real changes, just prefer using wxLocaleIdent to strings in a few
places.
This commit is contained in:
Vadim Zeitlin
2021-09-05 00:42:09 +02:00
parent 6f4dd01b5b
commit c7ad052c71
3 changed files with 54 additions and 37 deletions

View File

@@ -1014,7 +1014,21 @@ bool wxLocale::IsAvailable(int lang)
// Test if setting the locale works, then set it back.
char * const oldLocale = wxStrdupA(setlocale(LC_ALL, NULL));
const bool available = wxSetlocaleTryAll(LC_ALL, info->CanonicalName);
wxLocaleIdent locId;
wxString region;
locId.Language(info->CanonicalName.BeforeFirst('_', &region));
if ( !region.empty() )
{
// We never have encoding in our canonical names, but we can have
// modifiers, so take them into account.
wxString mod;
locId.Region(region.BeforeFirst('@', &mod));
if ( !mod.empty() )
locId.Modifier(mod);
}
const bool available = wxSetlocaleTryAll(LC_ALL, locId);
// restore the original locale
wxSetlocale(LC_ALL, oldLocale);