Allow creating wxUILocale objects for any locale
Creating such objects (without using them for the UI) is supported under all platforms, so allow doing it. Note that this is only supported under Unix systems when locale_t and related functionality is available, but this should be the case just about everywhere by now. Add a test (or, rather, replace an existing test which was disabled by default) checking that we can now get locale information about any locale, not necessarily the currently used one.
This commit is contained in:
@@ -37,6 +37,31 @@ wxUILocale wxUILocale::ms_current;
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
|
||||
/* static */
|
||||
wxUILocaleImpl* wxUILocaleImpl::CreateForLanguage(const wxLanguageInfo& info)
|
||||
{
|
||||
wxLocaleIdent locId;
|
||||
|
||||
// Strings in our language database are of the form "lang[_region[@mod]]".
|
||||
wxString rest;
|
||||
locId.Language(info.CanonicalName.BeforeFirst('_', &rest));
|
||||
|
||||
if ( !rest.empty() )
|
||||
{
|
||||
wxString mod;
|
||||
locId.Region(rest.BeforeFirst('@', &mod));
|
||||
|
||||
if ( !mod.empty() )
|
||||
locId.Modifier(mod);
|
||||
}
|
||||
|
||||
return CreateForLocale(locId);
|
||||
}
|
||||
|
||||
#endif // !__WINDOWS__
|
||||
|
||||
/* static */
|
||||
bool wxUILocale::UseDefault()
|
||||
{
|
||||
@@ -84,6 +109,13 @@ const wxUILocale& wxUILocale::GetCurrent()
|
||||
return ms_current;
|
||||
}
|
||||
|
||||
wxUILocale::wxUILocale(const wxLocaleIdent& localeId)
|
||||
{
|
||||
m_impl = wxUILocaleImpl::CreateForLocale(localeId);
|
||||
if ( !m_impl )
|
||||
m_impl = wxUILocaleImpl::CreateStdC();
|
||||
}
|
||||
|
||||
void wxUILocale::SetImpl(wxUILocaleImpl* impl)
|
||||
{
|
||||
delete m_impl;
|
||||
|
||||
Reference in New Issue
Block a user