diff options
author | Eike Rathke <erack@redhat.com> | 2013-08-28 19:02:02 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-08-28 19:21:58 +0200 |
commit | 8fb7cd5820b30df7140f89aa7991cf549f8370b0 (patch) | |
tree | 66284855d8e1d7aac1fc34fea9354f12fd79919e | |
parent | 0501026fb882de656887cb5af696f1cf7ceab3e9 (diff) |
makeFallback() with hierarchical retry
Change-Id: I459a9aefa65cb1e3e65e128bf9e2e323768acade
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 6c0581a1b513..4584acceb65a 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -1160,7 +1160,23 @@ LanguageTag & LanguageTag::makeFallback() if ( rLocale1.Language != aLocale2.Language || rLocale1.Country != aLocale2.Country || rLocale1.Variant != aLocale2.Variant) + { + if (rLocale1.Language != "en" && aLocale2.Language == "en" && aLocale2.Country == "US") + { + // "en-US" is the last resort fallback, try if we get a better + // one for the fallback hierarchy of a non-"en" locale. + ::std::vector< OUString > aFallbacks( getFallbackStrings()); + aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that + for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it) + { + lang::Locale aLocale3( LanguageTag( *it).getLocale()); + aLocale2 = MsLangId::Conversion::lookupFallbackLocale( aLocale3); + if (aLocale2.Language != "en" || aLocale2.Country != "US") + break; // for, success + } + } reset( aLocale2); + } mbIsFallback = true; } return *this; |