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

2020-07-23 Thread Jan Holesovsky (via logerrit)
 configmgr/source/access.cxx |   24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

New commits:
commit 9f8c77d87671ca0da124045d82cbe88fbaba3728
Author: Jan Holesovsky 
AuthorDate: Thu Jul 23 00:42:42 2020 +0200
Commit: Andras Timar 
CommitDate: Thu Jul 23 10:40:45 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/+/99263
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index e07fc8446f51..0308a0361761 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1385,29 +1385,25 @@ rtl::Reference< ChildAccess > Access::getChild(OUString 
const & name) {
 locale = comphelper::LibreOfficeKit::getLanguageTag().getBcp47();
 
 if (!locale.isEmpty()) {
-// Find best match using an adaptation 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 aFallbacks = 
LanguageTag(locale).getFallbackStrings(true);
+for (const OUString& rFallback : aFallbacks)
+{
+rtl::Reference 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)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-15 Thread Andras Timar (via logerrit)
 configmgr/source/access.cxx  |2 +-
 sd/source/core/CustomAnimationPreset.cxx |4 ++--
 sd/source/core/TransitionPreset.cxx  |4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit b516089abd4ec2ec615cdf15ea570ed1e4996cfe
Author: Andras Timar 
AuthorDate: Mon Jun 15 09:20:24 2020 +0200
Commit: Andras Timar 
CommitDate: Mon Jun 15 21:41:50 2020 +0200

Use  getBcp47() instead of getLanguage()

getLanguage() only returns the language code which can be
ambiguous in case of UI localization, when there are more
than one language variants. Fallback to the first variant
caused mixed language UI, e.g. en-US vs. en-GB, pt vs. pt-BR,
zh-CN vs. zh-TW.

Change-Id: I888423cd4b3c65dbdb900ff3b6bc308fa119be4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96284
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 9fe7f31cc00f..e07fc8446f51 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1382,7 +1382,7 @@ rtl::Reference< ChildAccess > Access::getChild(OUString 
const & name) {
 // here we override it with the actual current-user's language to
 // support per-view localization in LOK.
 if (comphelper::LibreOfficeKit::isActive())
-locale = 
comphelper::LibreOfficeKit::getLanguageTag().getLanguage();
+locale = comphelper::LibreOfficeKit::getLanguageTag().getBcp47();
 
 if (!locale.isEmpty()) {
 // Find best match using an adaptation of RFC 4647 lookup matching
diff --git a/sd/source/core/CustomAnimationPreset.cxx 
b/sd/source/core/CustomAnimationPreset.cxx
index e54c67d95b5c..426d8cc05924 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -507,8 +507,8 @@ const CustomAnimationPresets& 
CustomAnimationPresets::getCustomAnimationPresets(
 // Support localization per-view. Currently not useful for Desktop
 // but very much critical for LOK. The cache now is per-language.
 const OUString aLang = comphelper::LibreOfficeKit::isActive()
-   ? 
comphelper::LibreOfficeKit::getLanguageTag().getLanguage()
-   : 
SvtSysLocaleOptions().GetLanguageTag().getLanguage();
+   ? 
comphelper::LibreOfficeKit::getLanguageTag().getBcp47()
+   : 
SvtSysLocaleOptions().GetLanguageTag().getBcp47();
 
 SolarMutexGuard aGuard;
 const auto it = mPresetsMap.find(aLang);
diff --git a/sd/source/core/TransitionPreset.cxx 
b/sd/source/core/TransitionPreset.cxx
index 951959cdb69a..1a8f55b90aed 100644
--- a/sd/source/core/TransitionPreset.cxx
+++ b/sd/source/core/TransitionPreset.cxx
@@ -367,8 +367,8 @@ const TransitionPresetList& 
TransitionPreset::getTransitionPresetList()
 // Support localization per-view. Currently not useful for Desktop
 // but very much critical for LOK. The cache now is per-language.
 const OUString aLang = comphelper::LibreOfficeKit::isActive()
-   ? 
comphelper::LibreOfficeKit::getLanguageTag().getLanguage()
-   : 
SvtSysLocaleOptions().GetLanguageTag().getLanguage();
+   ? 
comphelper::LibreOfficeKit::getLanguageTag().getBcp47()
+   : 
SvtSysLocaleOptions().GetLanguageTag().getBcp47();
 
 SolarMutexGuard aGuard;
 const auto it = mPresetsMap.find(aLang);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits