[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - configmgr/source

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 28 07:37:36 UTC 2020


 configmgr/source/access.cxx |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

New commits:
commit 4c023e32a8116f2300407372204e3f6b426f2b71
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Jul 23 00:42:42 2020 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Jul 28 09:37:05 2020 +0200

    configmgr: Use a proper LanguageTag-based locale fallback mechanism.
    
    Without this, zh-Hant-TW locale used via the LibreOfficeKit was reduced
    to zh-Hant and further to zh, which was interpreted as zh-CN, causing
    incorrect strings particularly in the sidebar.
    
    Change-Id: I58e53f71d13824e422a7b3634f3822d55090f8ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99262
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 0c89942cb0c8..8957ed7841c5 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1390,29 +1390,25 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
             locale = comphelper::LibreOfficeKit::getLanguageTag().getBcp47();
 
         if (!locale.isEmpty()) {
-            // Find best match using an adaption of RFC 4647 lookup matching
-            // rules, removing "-" or "_" delimited segments from the end:
-            for (;;) {
-                rtl::Reference< ChildAccess > child(getChild(locale));
-                if (child.is()) {
+            // Find the best match using the LanguageTag fallback mechanism
+            std::vector<OUString> aFallbacks = LanguageTag(locale).getFallbackStrings(true);
+            for (const OUString& rFallback : aFallbacks)
+            {
+                rtl::Reference<ChildAccess> child(getChild(rFallback));
+                if (child.is())
                     return child;
-                }
-                sal_Int32 i = locale.getLength() - 1;
-                while (i > 0 && locale[i] != '-' && locale[i] != '_') {
-                    --i;
-                }
-                if (i <= 0) {
-                    break;
-                }
-                locale = locale.copy(0, i);
             }
+
             // As a workaround for broken xcu data that does not use shortest
             // xml:lang attributes, look for the first entry with the same first
             // segment as the requested language tag before falling back to
             // defaults (see fdo#33638):
+            assert(aFallbacks.size() > 0);
+            locale = aFallbacks[aFallbacks.size() - 1];
             assert(
                 !locale.isEmpty() && locale.indexOf('-') == -1 &&
                 locale.indexOf('_') == -1);
+
             std::vector< rtl::Reference< ChildAccess > > children(
                 getAllChildren());
             for (auto const& child : children)


More information about the Libreoffice-commits mailing list