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

Eike Rathke erack at redhat.com
Wed Aug 28 10:22:21 PDT 2013


 i18nlangtag/qa/cppunit/test_languagetag.cxx    |   21 +++++++++++++++++----
 i18nlangtag/source/languagetag/languagetag.cxx |   19 +++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)

New commits:
commit e362f9fcd7f50d750e8549d7b93a0a9a66cbabe1
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 28 19:20:26 2013 +0200

    added SAL_INFO to makeFallback()
    
    Change-Id: I121e0bd6004a736c7a64fb24ebc58ad784543bd1

diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 4584acc..ca4fa41 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -1175,6 +1175,9 @@ LanguageTag & LanguageTag::makeFallback()
                         break;  // for, success
                 }
             }
+            SAL_INFO( "i18nlangtag", "LanguageTag::makeFallback - for (" <<
+                    rLocale1.Language << "," << rLocale1.Country << "," << rLocale1.Variant << ") to (" <<
+                    aLocale2.Language << "," << aLocale2.Country << "," << aLocale2.Variant << ")");
             reset( aLocale2);
         }
         mbIsFallback = true;
commit f17232c2c500a95439b1faf5a637a239579bd4c9
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 28 19:13:21 2013 +0200

    added makeFallback() checks to unit test
    
    Change-Id: I1851e4eb821d1230df7268378c786d55a8652f9d

diff --git a/i18nlangtag/qa/cppunit/test_languagetag.cxx b/i18nlangtag/qa/cppunit/test_languagetag.cxx
index bab75f2..915d5cb 100644
--- a/i18nlangtag/qa/cppunit/test_languagetag.cxx
+++ b/i18nlangtag/qa/cppunit/test_languagetag.cxx
@@ -80,6 +80,7 @@ void TestLanguageTag::testAllTags()
         CPPUNIT_ASSERT( de_DE.getScript() == "Latn" );
         CPPUNIT_ASSERT( de_DE.getLanguageAndScript() == "de-Latn" );
 #endif
+        CPPUNIT_ASSERT( de_DE.makeFallback().getBcp47() == "de-DE");
     }
 
     {
@@ -171,6 +172,12 @@ void TestLanguageTag::testAllTags()
         CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[1] == "ca-valencia");
         CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[2] == "ca-ES");
         CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[3] == "ca");
+        /* TODO: conversion doesn't know this yet, once it does activate test. */
+#if 0
+        CPPUNIT_ASSERT( ca_ES_valencia.makeFallback().getBcp47() == "ca-ES-valencia");
+#else
+        CPPUNIT_ASSERT( ca_ES_valencia.makeFallback().getBcp47() == "ca-ES");
+#endif
     }
 
     {
@@ -193,6 +200,12 @@ void TestLanguageTag::testAllTags()
         CPPUNIT_ASSERT( ca_valencia_Fallbacks.size() == 2);
         CPPUNIT_ASSERT( ca_valencia_Fallbacks[0] == "ca-valencia");
         CPPUNIT_ASSERT( ca_valencia_Fallbacks[1] == "ca");
+        /* TODO: conversion doesn't know this yet, once it does activate test. */
+#if 0
+        CPPUNIT_ASSERT( ca_valencia.makeFallback().getBcp47() == "ca-ES-valencia");
+#else
+        CPPUNIT_ASSERT( ca_valencia.makeFallback().getBcp47() == "ca-ES");
+#endif
     }
 
     {
commit 2c00c8fb5a907d3f337a6b3f3ba6958700e932bd
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 28 19:05:40 2013 +0200

    again match some copy&paste names
    
    Change-Id: Iddfe959568f73f71827d9c1c651087ec93cbc941

diff --git a/i18nlangtag/qa/cppunit/test_languagetag.cxx b/i18nlangtag/qa/cppunit/test_languagetag.cxx
index 49c6c5f..bab75f2 100644
--- a/i18nlangtag/qa/cppunit/test_languagetag.cxx
+++ b/i18nlangtag/qa/cppunit/test_languagetag.cxx
@@ -189,10 +189,10 @@ void TestLanguageTag::testAllTags()
         CPPUNIT_ASSERT( ca_valencia.getCountry() == "" );
         CPPUNIT_ASSERT( ca_valencia.getScript() == "" );
         CPPUNIT_ASSERT( ca_valencia.getLanguageAndScript() == "ca" );
-        ::std::vector< OUString > ca_ES_valencia_Fallbacks( ca_valencia.getFallbackStrings());
-        CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks.size() == 2);
-        CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[0] == "ca-valencia");
-        CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[1] == "ca");
+        ::std::vector< OUString > ca_valencia_Fallbacks( ca_valencia.getFallbackStrings());
+        CPPUNIT_ASSERT( ca_valencia_Fallbacks.size() == 2);
+        CPPUNIT_ASSERT( ca_valencia_Fallbacks[0] == "ca-valencia");
+        CPPUNIT_ASSERT( ca_valencia_Fallbacks[1] == "ca");
     }
 
     {
commit 8fb7cd5820b30df7140f89aa7991cf549f8370b0
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 28 19:02:02 2013 +0200

    makeFallback() with hierarchical retry
    
    Change-Id: I459a9aefa65cb1e3e65e128bf9e2e323768acade

diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 6c0581a..4584acc 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -1160,7 +1160,23 @@ LanguageTag & LanguageTag::makeFallback()
         if (    rLocale1.Language != aLocale2.Language ||
                 rLocale1.Country  != aLocale2.Country ||
                 rLocale1.Variant  != aLocale2.Variant)
+        {
+            if (rLocale1.Language != "en" && aLocale2.Language == "en" && aLocale2.Country == "US")
+            {
+                // "en-US" is the last resort fallback, try if we get a better
+                // one for the fallback hierarchy of a non-"en" locale.
+                ::std::vector< OUString > aFallbacks( getFallbackStrings());
+                aFallbacks.erase( aFallbacks.begin());  // first is full BCP47, we already checked that
+                for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
+                {
+                    lang::Locale aLocale3( LanguageTag( *it).getLocale());
+                    aLocale2 = MsLangId::Conversion::lookupFallbackLocale( aLocale3);
+                    if (aLocale2.Language != "en" || aLocale2.Country != "US")
+                        break;  // for, success
+                }
+            }
             reset( aLocale2);
+        }
         mbIsFallback = true;
     }
     return *this;


More information about the Libreoffice-commits mailing list