diff options
author | Eike Rathke <erack@redhat.com> | 2017-09-12 16:56:00 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-09-12 16:57:55 +0200 |
commit | 82ee2ad282c3548e7ce6e745c8aee0db8b9b2201 (patch) | |
tree | 5daa217004f30530f0562eda27a88c5db4ebf181 | |
parent | 98034b25ee3a2d4b1a98a48c22b21ef2f7ec8b23 (diff) |
Handle 'es-ES_tradnl' and 'es-ES-u-co-trad' as known, tdf#83190 follow-up
LanguageTagImpl::simpleExtract() needs to handle them because for known tags
mpImplLangtag is not used to extract language, country, region; which for the
malformed 'es-ES_tradnl' wouldn't work anyway.
Change-Id: I1efcf32e90e513d5af4624c7ae15848d1fe951a7
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 684364ff1c81..c57514cbd977 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -335,7 +335,8 @@ private: EXTRACTED_LV, EXTRACTED_C_LOCALE, EXTRACTED_X, - EXTRACTED_X_JOKER + EXTRACTED_X_JOKER, + EXTRACTED_KNOWN_BAD }; /** Of a language tag of the form lll[-Ssss][-CC][-vvvvvvvv] extract the @@ -349,6 +350,7 @@ private: EXTRACTED_C_LOCALE if a 'C' locale was detected, EXTRACTED_X if x-... privateuse tag was detected, EXTRACTED_X_JOKER if "*" joker was detected, + EXTRACTED_KNOWN_BAD if a bad but known (to be remapped) tag was detected EXTRACTED_NONE else. */ static Extraction simpleExtract( const OUString& rBcp47, @@ -2511,6 +2513,26 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp eRet = EXTRACTED_LV; } } + else if ( (nHyph1 == 2 && nHyph2 == 5 && nHyph3 == 7) // ll-CC-u-... + || (nHyph1 == 3 && nHyph2 == 6 && nHyph3 == 8)) // lll-CC-u-... + { + if (rBcp47[nHyph3-1] == 'u') + { + // Need to recognize as known, otherwise getLanguage() and + // getCountry() return empty string because mpImplLangtag is not + // used with a known mapping. + /* TODO: if there were more this would get ugly and needed some + * table driven approach via isolang.cxx instead. */ + if (rBcp47.equalsIgnoreAsciiCase( "es-ES-u-co-trad")) + { + rLanguage = "es"; + rScript.clear(); + rCountry = "ES"; + rVariants = "u-co-trad"; // not strictly a variant, but used to reconstruct the tag. + eRet = EXTRACTED_LV; + } + } + } else if ( (nHyph1 == 2 && nHyph2 == 5 && nLen >= 10) // ll-CC-vvvv[vvvv][-...] || (nHyph1 == 3 && nHyph2 == 6 && nLen >= 11)) // lll-CC-vvvv[vvvv][-...] { @@ -2551,6 +2573,16 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp rVariants = "oed"; eRet = EXTRACTED_LV; } + // Other known and handled odd cases. + else if (rBcp47.equalsIgnoreAsciiCase( "es-ES_tradnl")) + { + // Will get overridden, but needs to be recognized as known. + rLanguage = "es"; + rScript.clear(); + rCountry = "ES"; + rVariants = "tradnl"; // this is nonsense, but.. ignored. + eRet = EXTRACTED_KNOWN_BAD; + } } } if (eRet == EXTRACTED_NONE) |