Fix incorrect assumptions about locales codes.
wx incorrectly assumes that Unix locale codes have the form of xx_YY, where both xx and yy are two characters long. This is wrong, xx is ISO 639 code, which can often have 3 characters ("ast", "gez" etc.); future ISO 639-6 will have up to 4 chars. Similarly, ISO 3166 has alpha-3 variant of country codes too (even though they aren't used in this context today). For parsing needs, we can just look for '_' in the code. The only place where a check for xx_YY code was performed was GetSystemLanguage(). Instead of bothering with correct check (or a heuristic), let's simply assume locale is xx_YY code and only do alternative handling if that assumption fails. According to the comments, this alternative handling was for cases such as LANG=german environment on SuSE, but it's safe to say that no modern systems do that anymore, so it's OK that this patch is marginally less efficient on such legacy systems. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -65,25 +65,6 @@ const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
|
||||
|
||||
#define TRACE_I18N wxS("i18n")
|
||||
|
||||
// the constants describing the format of ll_CC locale string
|
||||
static const size_t LEN_LANG = 2;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// get just the language part
|
||||
inline wxString ExtractLang(const wxString& langFull)
|
||||
{
|
||||
return langFull.Left(LEN_LANG);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
@@ -1428,9 +1409,10 @@ bool wxTranslations::LoadCatalog(const wxString& domain, const wxString& lang)
|
||||
// Also try just base locale name: for things like "fr_BE" (Belgium
|
||||
// French) we should use fall back on plain "fr" if no Belgium-specific
|
||||
// message catalogs exist
|
||||
if ( lang.length() > LEN_LANG && lang[LEN_LANG] == wxS('_') )
|
||||
wxString baselang = lang.BeforeFirst('_');
|
||||
if ( lang != baselang )
|
||||
{
|
||||
if ( m_loader->LoadCatalog(this, domain, ExtractLang(lang)) )
|
||||
if ( m_loader->LoadCatalog(this, domain, baselang) )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1772,9 +1754,6 @@ bool wxFileTranslationsLoader::LoadCatalog(wxTranslations *translations,
|
||||
const wxString& domain,
|
||||
const wxString& lang)
|
||||
{
|
||||
wxCHECK_MSG( lang.length() >= LEN_LANG, false,
|
||||
"invalid language specification" );
|
||||
|
||||
wxString searchPath = GetFullSearchPath(lang);
|
||||
|
||||
wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in search path \"%s\""),
|
||||
|
Reference in New Issue
Block a user