summaryrefslogtreecommitdiffstats
path: root/i18nlangtag
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-12-15 14:24:39 +0100
committerEike Rathke <erack@redhat.com>2021-12-15 19:50:24 +0100
commit7c22bed187c12122fe29459279771ca414799ac8 (patch)
tree0843a3f3400521c6ad9b4fdac6e8dc44da5565b1 /i18nlangtag
parentunset mpMenuBarWidget when it was destroyed along with its parent (diff)
downloadcore-7c22bed187c12122fe29459279771ca414799ac8.tar.gz
core-7c22bed187c12122fe29459279771ca414799ac8.zip
Related: tdf#146228 convertIsoNamesToLanguage() fallback for empty tag
An empty tag might be the result of a bad LANGUAGE=":" setting. The old implementation tried an unconditional "-" tag (for both language and country empty) that was wrong anyway. Do not keep the resulting LANGUAGE_SYSTEM as that is exactly what we want to know the actual locale for. Change-Id: I7d6587f59e9a3362c7d877926a325ebcfe7b48db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126863 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'i18nlangtag')
-rw-r--r--i18nlangtag/source/isolang/isolang.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index bf8c5d4b5d34..36b69f0fe6a6 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -1408,10 +1408,12 @@ LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( std::string_view r
// actually call into LanguageTag to create an on-the-fly mapping.
if (nLang == LANGUAGE_DONTKNOW)
{
- nLang = LanguageTag( aLang + "-" + aCountry).getLanguageType(false);
+ OUString aTag( aCountry.isEmpty() ? aLang : aLang + "-" + aCountry );
+ nLang = LanguageTag( aTag).getLanguageType(false);
SAL_WARN("i18nlangtag", "convertIsoNamesToLanguage(string_view): on-the-fly for {"
- << aLang << "-" << aCountry << "} " << nLang);
- if (nLang == LANGUAGE_DONTKNOW)
+ << aTag << "} " << nLang);
+ // Do not leave empty as SYSTEM unresolved.
+ if (nLang == LANGUAGE_DONTKNOW || nLang == LANGUAGE_SYSTEM)
{
SAL_WARN("i18nlangtag", "convertIsoNamesToLanguage(string_view): on-the-fly bad, using {en-US}");
nLang = LANGUAGE_ENGLISH_US;