[Libreoffice-commits] core.git: 2 commits - i18npool/inc i18npool/source vcl/unx

Eike Rathke erack at redhat.com
Thu Mar 28 07:00:07 PDT 2013


 i18npool/inc/i18npool/languagetag.hxx       |   13 +++++++++++++
 i18npool/source/languagetag/languagetag.cxx |   23 +++++++++++++++++++++++
 vcl/unx/gtk/fpicker/SalGtkPicker.cxx        |   13 +++----------
 3 files changed, 39 insertions(+), 10 deletions(-)

New commits:
commit 0b0f22311b0cf24e795d3f8eb12f19c357485fed
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Mar 28 14:58:49 2013 +0100

    use LanguageTag::getGlibcLocaleString()
    
    Change-Id: I86a5aad4c1a024861c82d44a3f67a2cbe00e7c2f

diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
index b4c08b5..db74fc7 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
@@ -179,18 +179,11 @@ void SalGtkPicker::setGtkLanguage()
     if (bSet)
         return;
 
-    /* FIXME-BCP47: let LanguageTag create glibc locale string! */
-    ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
-    rtl::OUStringBuffer aBuffer;
-    aBuffer.append( aLocale.Language );
-    aBuffer.appendAscii( "_" );
-    aBuffer.append( aLocale.Country );
-    aBuffer.appendAscii( ".UTF-8" );
-
-    if (aBuffer.getLength() > 8)
+    OUString aLocaleString( Application::GetSettings().GetUILanguageTag().getGlibcLocaleString( ".UTF-8"));
+    if (!aLocaleString.isEmpty())
     {
         rtl::OUString envVar( "LANGUAGE" );
-        osl_setEnvironment( envVar.pData, aBuffer.makeStringAndClear().pData );
+        osl_setEnvironment( envVar.pData, aLocaleString.pData );
     }
     bSet = true;
 }
commit 33f26ca42f37a9336c9bf2982fc1c9ef0d0f27d5
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Mar 28 14:51:21 2013 +0100

    added LanguageTag::getGlibcLocaleString()
    
    Change-Id: I5e77026f5c016d912fa342a5e1bca08eb445b15c

diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx
index eb1a518..0bba7a1 100644
--- a/i18npool/inc/i18npool/languagetag.hxx
+++ b/i18npool/inc/i18npool/languagetag.hxx
@@ -158,6 +158,19 @@ public:
      */
     OUString                        getRegion() const;
 
+    /** Get a GLIBC locale string.
+
+        Always resolves an empty tag to the system locale.
+
+        @param  rEncoding
+                An encoding to be appended to language_country, for example
+                ".UTF-8" including the dot.
+
+        @return The resulting GLIBC locale string if it could be constructed,
+                if not an empty string is returned.
+     */
+    OUString                        getGlibcLocaleString( const OUString & rEncoding ) const;
+
     /** If language tag has a non-default script specified.
      */
     bool                            hasScript() const;
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx
index 961c8d5..99b12cf 100644
--- a/i18npool/source/languagetag/languagetag.cxx
+++ b/i18npool/source/languagetag/languagetag.cxx
@@ -950,6 +950,29 @@ OUString LanguageTag::getRegion() const
 }
 
 
+OUString LanguageTag::getGlibcLocaleString( const OUString & rEncoding ) const
+{
+    OUString aRet;
+    if (isIsoLocale())
+    {
+        OUString aCountry( getCountry());
+        if (aCountry.isEmpty())
+            aRet = getLanguage() + rEncoding;
+        else
+            aRet = getLanguage() + "_" + aCountry + rEncoding;
+    }
+    else
+    {
+        /* FIXME: use the aImplIsoLangGLIBCModifiersEntries table from
+         * i18npool/source/isolang/isolang.cxx or let liblangtag handle it. So
+         * far no code was prepared for anything else than a simple
+         * language_country locale so we don't loose anything here right now.
+         * */
+    }
+    return aRet;
+}
+
+
 bool LanguageTag::hasScript() const
 {
     if (!mbCachedScript)


More information about the Libreoffice-commits mailing list