From aec5312ffab24236876693d7a8b55843847f2a48 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Mon, 18 Oct 2021 20:02:55 +0200 Subject: Related: tdf#145173 Ensure known supported system and default document locale For an unsupported locale like {en-IL} that could had ended up as language-only {en} if the aImplIsoLangEntries map contains such entry as obtained through MsLangId::convertUnxByteStringToLanguage() and Conversion::convertIsoNamesToLanguage(). For the system locale in SvtSysLocale a proper fallback is used but the default document language was propagated as is Other places evaluating MsLangId::getSystemLanguage() are affected as well, those probably will have to be replaced by a call to MsLangId::getRealLanguage(LANGUAGE_SYSTEM) or a newly to be introduced MsLangId::getConfiguredSystemLanguage() and MsLangId::getSystemLanguage() be made private or accessible only by LanguageTag. Change-Id: I87eb9456d5b4ea8d64b0c41fec6bd2739256fb56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123756 Reviewed-by: Eike Rathke Tested-by: Jenkins --- desktop/source/app/langselect.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'desktop/source/app/langselect.cxx') diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 2958ed8786b5..8a07e26c3134 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -121,11 +121,18 @@ bool prepareLocale() { } MsLangId::setConfiguredSystemUILanguage(tag.getLanguageType(false)); + // Note the system language/locale here may or may not be correct before we + // actually set it below. It is what could be figured from the system + // setting and may only partially match, like "en" for an unsupported + // English locale. + LanguageTag aSysLocTag( MsLangId::getSystemLanguage()); OUString setupSysLoc(officecfg::Setup::L10N::ooSetupSystemLocale::get()); - LanguageTag::setConfiguredSystemLanguage( - setupSysLoc.isEmpty() - ? MsLangId::getSystemLanguage() - : LanguageTag(setupSysLoc).getLanguageType(false)); + if (!setupSysLoc.isEmpty()) + aSysLocTag.reset( setupSysLoc); + // Ensure the system locale is set to a known supported locale. + aSysLocTag.makeFallback(); + LanguageTag::setConfiguredSystemLanguage( aSysLocTag.getLanguageType(false)); + // #i32939# setting of default document locale // #i32939# this should not be based on the UI language // So obtain the system locale now configured just above and pass it on, -- cgit