[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - i18nlangtag/source i18npool/source include/i18nlangtag

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 24 15:33:33 UTC 2018


 i18nlangtag/source/languagetag/languagetagicu.cxx |    6 ++++--
 i18npool/source/collator/collator_unicode.cxx     |   12 ++++++++++--
 include/i18nlangtag/languagetagicu.hxx            |    7 +++----
 3 files changed, 17 insertions(+), 8 deletions(-)

New commits:
commit 5bec6b86cb08b814076f4bf51aee1547f13b61ec
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sat Aug 11 00:23:25 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Fri Aug 24 17:33:09 2018 +0200

    tdf#119117: get phonebook sort work by tweaking ICU call mechanism
    
    Using "phonebook" as variant does't work with de_DE
    since it gives de_DE_PHONEBOOK whereas icu expects de__PHONEBOOK
    See http://userguide.icu-project.org/locale#TOC-Variant-code,
       Level 2 canonicalization, 8.
    
    So let variant empty and use the fourth arg of icuLocale "keywords"
    
    See constructors in http://icu-project.org/apiref/icu4c/classicu_1_1Locale.html
    
    Change-Id: I6c216c86cdd32abfa477c14a80d1b8794b536900
    Reviewed-on: https://gerrit.libreoffice.org/58870
    (cherry picked from commit 13db6e8671c36e1a028d6a8ad63f518e60f84870)
    Reviewed-on: https://gerrit.libreoffice.org/59278
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx b/i18nlangtag/source/languagetag/languagetagicu.cxx
index 33a98844043f..18d37f704773 100644
--- a/i18nlangtag/source/languagetag/languagetagicu.cxx
+++ b/i18nlangtag/source/languagetag/languagetagicu.cxx
@@ -35,13 +35,15 @@ icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag )
 
 
 // static
-icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant )
+icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant, const OUString & rKeywords )
 {
     /* FIXME: how should this work with any BCP47? */
     return icu::Locale(
             OUStringToOString( rLanguageTag.getLanguage(), RTL_TEXTENCODING_ASCII_US).getStr(),
             OUStringToOString( rLanguageTag.getCountry(), RTL_TEXTENCODING_ASCII_US).getStr(),
-            OUStringToOString( rVariant, RTL_TEXTENCODING_ASCII_US).getStr());
+            OUStringToOString( rVariant, RTL_TEXTENCODING_ASCII_US).getStr(),
+            OUStringToOString( rKeywords, RTL_TEXTENCODING_ASCII_US).getStr()
+           );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx
index 5bbe015e4d5e..d3e189a5ff1d 100644
--- a/i18npool/source/collator/collator_unicode.cxx
+++ b/i18npool/source/collator/collator_unicode.cxx
@@ -367,10 +367,18 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang::
             /** ICU collators are loaded using a locale only.
                 ICU uses Variant as collation algorithm name (like de__PHONEBOOK
                 locale), note the empty territory (Country) designator in this special
-                case here. The icu::Locale constructor changes the algorithm name to
+                case here.
+                But sometimes the mapping fails, eg for German (from Germany) phonebook, we'll have "de_DE_PHONEBOOK"
+                this one won't be remapping to collation keyword specifiers "de at collation=phonebook"
+                See http://userguide.icu-project.org/locale#TOC-Variant-code, Level 2 canonicalization, 8.
+                So let variant empty and use the fourth arg of icuLocale "keywords"
+                See LanguageTagIcu::getIcuLocale from i18nlangtag/source/languagetag/languagetagicu.cxx
+                The icu::Locale constructor changes the algorithm name to
                 uppercase itself, so we don't have to bother with that.
             */
-            icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale), rAlgorithm));
+            icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale),
+                        "", rAlgorithm.isEmpty() ? OUString("") : "collation=" + rAlgorithm));
+
             // load ICU collator
             collator.reset( static_cast<icu::RuleBasedCollator*>( icu::Collator::createInstance(icuLocale, status) ) );
             if (! U_SUCCESS(status)) throw RuntimeException();
diff --git a/include/i18nlangtag/languagetagicu.hxx b/include/i18nlangtag/languagetagicu.hxx
index 2d0aabdd34ea..e2c9f7ce2b0e 100644
--- a/include/i18nlangtag/languagetagicu.hxx
+++ b/include/i18nlangtag/languagetagicu.hxx
@@ -41,13 +41,12 @@ public:
     /** Obtain language tag as ICU icu::Locale, adding variant data.
 
         From the LanguageTag only language and country are used to construct
-        the icu:Locale, the variant field is copied from rVariant. For example
-        needed to create an icu::Collator instance where the variant field
-        denotes the algorithm to be used.
+        the icu:Locale, the variant field is copied from rVariant.
+        The 4th arg of icu::Locale "keywords" (eg: for collation)
 
         Always resolves an empty tag to the system locale.
      */
-    static  icu::Locale     getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant );
+    static  icu::Locale     getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant, const OUString & rKeywords);
 };
 
 #endif  // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX


More information about the Libreoffice-commits mailing list