[Libreoffice-commits] core.git: i18nlangtag/qa i18nlangtag/source include/i18nlangtag

Eike Rathke erack at redhat.com
Thu Jul 9 16:25:31 PDT 2015


 i18nlangtag/qa/cppunit/test_languagetag.cxx    |   34 ++++++++++++++++++++++---
 i18nlangtag/source/isolang/isolang.cxx         |    3 +-
 i18nlangtag/source/languagetag/languagetag.cxx |    9 ++++++
 include/i18nlangtag/lang.h                     |    1 
 4 files changed, 42 insertions(+), 5 deletions(-)

New commits:
commit 122a15f4a6c09d35db58fe3a7b943b5ea79cbe65
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jul 10 01:15:50 2015 +0200

    support en-GB-oxendict additionally to now deprecated en-GB-oed
    
    Have them separated so when saving loaded documents the same tag is used
    to keep the generator happy.
    
    When to switch in UI language listbox? Or should we have both entries?
    
    Change-Id: If78600229c4b24f6ee598c25d5a8974fef410bb5

diff --git a/i18nlangtag/qa/cppunit/test_languagetag.cxx b/i18nlangtag/qa/cppunit/test_languagetag.cxx
index b76547c..773465b 100644
--- a/i18nlangtag/qa/cppunit/test_languagetag.cxx
+++ b/i18nlangtag/qa/cppunit/test_languagetag.cxx
@@ -420,7 +420,8 @@ void TestLanguageTag::testAllTags()
     }
 
     // 'en-GB-oed' is known grandfathered for English, Oxford English
-    // Dictionary spelling
+    // Dictionary spelling.
+    // Deprecated as of 2015-04-17, prefer en-GB-oxendict instead.
     {
         OUString s_en_GB_oed( "en-GB-oed" );
         LanguageTag en_GB_oed( s_en_GB_oed );
@@ -436,13 +437,38 @@ void TestLanguageTag::testAllTags()
         CPPUNIT_ASSERT( en_GB_oed.getLanguageAndScript() == "en" );
         CPPUNIT_ASSERT( en_GB_oed.getVariants() == "oed" );
         ::std::vector< OUString > en_GB_oed_Fallbacks( en_GB_oed.getFallbackStrings( true));
-        CPPUNIT_ASSERT( en_GB_oed_Fallbacks.size() == 3);
+        CPPUNIT_ASSERT( en_GB_oed_Fallbacks.size() == 4);
         CPPUNIT_ASSERT( en_GB_oed_Fallbacks[0] == "en-GB-oed");
-        CPPUNIT_ASSERT( en_GB_oed_Fallbacks[1] == "en-GB");
-        CPPUNIT_ASSERT( en_GB_oed_Fallbacks[2] == "en");
+        CPPUNIT_ASSERT( en_GB_oed_Fallbacks[1] == "en-GB-oxendict");
+        CPPUNIT_ASSERT( en_GB_oed_Fallbacks[2] == "en-GB");
+        CPPUNIT_ASSERT( en_GB_oed_Fallbacks[3] == "en");
         // 'en-oed' is not a valid fallback!
     }
 
+    // 'en-GB-oxendict' as preferred over 'en-GB-oed'.
+    {
+        OUString s_en_GB_oxendict( "en-GB-oxendict" );
+        LanguageTag en_GB_oxendict( s_en_GB_oxendict );
+        lang::Locale aLocale = en_GB_oxendict.getLocale();
+        CPPUNIT_ASSERT( en_GB_oxendict.getBcp47() == s_en_GB_oxendict );
+        CPPUNIT_ASSERT( aLocale.Language == "qlt" );
+        CPPUNIT_ASSERT( aLocale.Country == "GB" );
+        CPPUNIT_ASSERT( aLocale.Variant == s_en_GB_oxendict );
+        CPPUNIT_ASSERT( en_GB_oxendict.getLanguageType() == LANGUAGE_USER_ENGLISH_UK_OXENDICT );
+        CPPUNIT_ASSERT( en_GB_oxendict.isValidBcp47() );
+        CPPUNIT_ASSERT( !en_GB_oxendict.isIsoLocale() );
+        CPPUNIT_ASSERT( !en_GB_oxendict.isIsoODF() );
+        CPPUNIT_ASSERT( en_GB_oxendict.getLanguageAndScript() == "en" );
+        CPPUNIT_ASSERT( en_GB_oxendict.getVariants() == "oxendict" );
+        ::std::vector< OUString > en_GB_oxendict_Fallbacks( en_GB_oxendict.getFallbackStrings( true));
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks.size() == 5);
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks[0] == "en-GB-oxendict");
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks[1] == "en-GB-oed");
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks[2] == "en-oxendict");
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks[3] == "en-GB");
+        CPPUNIT_ASSERT( en_GB_oxendict_Fallbacks[4] == "en");
+    }
+
 #if USE_LIBLANGTAG
     // 'zh-yue-HK' uses redundant 'zh-yue' and should be preferred 'yue-HK'
 #if 0
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index e0b1383..157598d5 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -741,7 +741,8 @@ static Bcp47CountryEntry const aImplBcp47CountryEntries[] =
     // MS-LangID                              full BCP47, ISO3166, ISO639-Variant or other fallback
     { LANGUAGE_CATALAN_VALENCIAN,       "ca-ES-valencia", "ES", "ca-valencia" },
     { LANGUAGE_OBSOLETE_USER_CATALAN_VALENCIAN, "ca-ES-valencia", "ES", "" },   // In case MS format files using the old value escaped into the wild, map them back.
-    { LANGUAGE_USER_ENGLISH_UK_OED,          "en-GB-oed", "GB", "" },   // grandfathered
+    { LANGUAGE_USER_ENGLISH_UK_OED,          "en-GB-oed", "GB", "" },   // grandfathered, deprecated, prefer en-GB-oxendict
+    { LANGUAGE_USER_ENGLISH_UK_OXENDICT,"en-GB-oxendict", "GB", "" },
 //  { LANGUAGE_YUE_CHINESE_HONGKONG,         "zh-yue-HK", "HK", "" },   // MS reserved, prefer yue-HK; do not add unless LanguageTag::simpleExtract() can handle it to not call liblangtag for rsc!
     { LANGUAGE_DONTKNOW,                    "", "", "" }    // marks end of table
 };
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 15cf405..906c7b3 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -2150,6 +2150,15 @@ LanguageTag & LanguageTag::makeFallback()
     getBcp47();     // have maBcp47 now
     if (bIncludeFullBcp47)
         aVec.push_back( maBcp47);
+
+    // Special cases for deprecated tags and their replacements, include both
+    // in fallbacks in a sensible order.
+    /* TODO: could such things be generalized and automated with liblangtag? */
+    if (maBcp47 == "en-GB-oed")
+        aVec.push_back( "en-GB-oxendict");
+    else if (maBcp47 == "en-GB-oxendict")
+        aVec.push_back( "en-GB-oed");
+
     OUString aScript;
     OUString aVariants( getVariants());
     OUString aTmp;
diff --git a/include/i18nlangtag/lang.h b/include/i18nlangtag/lang.h
index 420c68a..fdfce88 100644
--- a/include/i18nlangtag/lang.h
+++ b/include/i18nlangtag/lang.h
@@ -706,6 +706,7 @@ typedef unsigned short LanguageType;
 #define LANGUAGE_USER_VENETIAN              0x0695
 #define LANGUAGE_USER_ENGLISH_GAMBIA        0x9009  /* makeLangID( 0x24, getPrimaryLanguage( LANGUAGE_ENGLISH_UK)) */
 #define LANGUAGE_USER_OCCITAN_ARANESE       0x8082  /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_OCCITAN_FRANCE)) */
+#define LANGUAGE_USER_ENGLISH_UK_OXENDICT   0x9409  /* makeLangID( 0x25, getPrimaryLanguage( LANGUAGE_ENGLISH_UK)) */
 
 
 /* Primary language ID range for on-the-fly assignment. */


More information about the Libreoffice-commits mailing list