Try an override locale as first fallback

Change-Id: I4ca6db43fef2706c4c1bab020e2170f6cf45a441
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147184
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
This commit is contained in:
Eike Rathke 2023-02-17 02:12:23 +01:00
parent 66719bbdf9
commit b52117c0be

View file

@ -1394,9 +1394,19 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
if (directChild.is())
return directChild;
LanguageTag aLanguageTag(locale, true);
if (aLanguageTag.getBcp47() != locale)
{
// Original may be overridden by a known locale, for example
// "zh-Hant-TW" by "zh-TW".
rtl::Reference<ChildAccess> child(getChild(aLanguageTag.getBcp47()));
if (child.is())
return child;
}
// Find the best match using the LanguageTag fallback mechanism,
// excluding the original tag.
std::vector<OUString> aFallbacks = LanguageTag(locale).getFallbackStrings(false);
std::vector<OUString> aFallbacks = aLanguageTag.getFallbackStrings(false);
for (const OUString& rFallback : aFallbacks)
{
rtl::Reference<ChildAccess> child(getChild(rFallback));