diff options
author | Eike Rathke <erack@redhat.com> | 2016-04-20 18:56:33 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-04-20 19:18:52 +0200 |
commit | b7e3c63f1a384a278da4f6515f5279dbd5f46772 (patch) | |
tree | 65f3947f3b6af31a9c2817dc6879233559bae10f /i18nlangtag/source/languagetag | |
parent | 100eb15b4d8529d7a11d98a28742f31f0f792fa1 (diff) |
explicitly map 'C' locale and other known definitions to LanguageTag
Starting up a dbgutil build with LC_ALL=C gave
i18nlangtag/source/languagetag/languagetag.cxx:1362:
LanguageTagImpl::convertLocaleToLang: with bAllowOnTheFlyID invalid 'C'
i18nlangtag/source/languagetag/languagetag.cxx:1533:
LanguageTag::getLanguageFromLangtag: pLangT==NULL for 'C'
i18nlangtag/source/languagetag/languagetag.cxx:1593:
LanguageTag::getRegionFromLangtag: pRegionT==NULL for 'C'
Nothing harmful in this case as the default fallback is 'en-US', but it
also indicated that other known non-standard "locales" such as
"sr-latin" or "german" were not resolved to the defined values. Likely
such weird values are not in use anymore, but..
Change-Id: Ib3469354ceb236552540da5fd11d8f9e9c5ab1fd
Diffstat (limited to 'i18nlangtag/source/languagetag')
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index e8df2a4a1593..fe0e2cf9a54b 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -293,7 +293,7 @@ private: bool isValidBcp47() const; void convertLocaleToBcp47(); - void convertLocaleToLang( bool bAllowOnTheFlyID ); + bool convertLocaleToLang( bool bAllowOnTheFlyID ); void convertBcp47ToLocale(); void convertBcp47ToLang(); void convertLangToLocale(); @@ -1137,7 +1137,8 @@ bool LanguageTagImpl::canonicalize() { if (!mbInitializedLangID) { - convertLocaleToLang( false); + if (convertLocaleToLang( false)) + bChanged = true; if (bTemporaryLocale || mnLangID == LANGUAGE_DONTKNOW) bTemporaryLangID = true; } @@ -1326,8 +1327,9 @@ void LanguageTagImpl::convertLocaleToBcp47() } -void LanguageTagImpl::convertLocaleToLang( bool bAllowOnTheFlyID ) +bool LanguageTagImpl::convertLocaleToLang( bool bAllowOnTheFlyID ) { + bool bRemapped = false; if (mbSystemLocale) { mnLangID = MsLangId::getRealLanguage( LANGUAGE_SYSTEM); @@ -1335,6 +1337,24 @@ void LanguageTagImpl::convertLocaleToLang( bool bAllowOnTheFlyID ) else { mnLangID = MsLangId::Conversion::convertLocaleToLanguage( maLocale); + if (mnLangID == LANGUAGE_DONTKNOW) + { + // convertLocaleToLanguage() only searches in ISO and private + // definitions, search in remaining definitions, i.e. for the "C" + // locale and non-standard things like "sr-latin" or "german" to + // resolve to a known locale, skipping ISO lll-CC that were already + // searched. + mnLangID = MsLangId::Conversion::convertIsoNamesToLanguage( maLocale.Language, maLocale.Country, true); + if (mnLangID != LANGUAGE_DONTKNOW) + { + // If one found, convert back and adapt Locale and Bcp47 + // strings so we have a matching entry. + OUString aOrgBcp47( maBcp47); + convertLangToLocale(); + convertLocaleToBcp47(); + bRemapped = (maBcp47 != aOrgBcp47); + } + } if (mnLangID == LANGUAGE_DONTKNOW && bAllowOnTheFlyID) { if (isValidBcp47()) @@ -1364,6 +1384,7 @@ void LanguageTagImpl::convertLocaleToLang( bool bAllowOnTheFlyID ) } } mbInitializedLangID = true; + return bRemapped; } |