[Libreoffice-commits] core.git: stoc/Library_javavm.mk stoc/source

Eike Rathke erack at redhat.com
Tue Oct 25 11:30:31 UTC 2016


 stoc/Library_javavm.mk        |    1 +
 stoc/source/javavm/javavm.cxx |   30 ++++++++++++++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

New commits:
commit 9b09a217c79e8a35fc4de54c89ef49fbf8f72752
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Oct 25 13:10:07 2016 +0200

    Resolves: #i86470# Wrong Java locale when using "nl" and "fr"
    
    Languages don't always have a country; if there is no "-" separating
    language and country in the ooLocale registry value, use the entire
    value as the language.
    
    Initial finding by Damjan Jovanovic.
    However, LibreOffice knows BCP47 language tags so that needs a different
    approach.
    
    (cherry picked from commit d61ab2b5a0e35d55cb001e139be791420245bf35)
    
    Change-Id: I69331951372bda1c1cec80cfd10d5839d8f4b823
    Reviewed-on: https://gerrit.libreoffice.org/30154
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/stoc/Library_javavm.mk b/stoc/Library_javavm.mk
index a45518c..fc4428d 100644
--- a/stoc/Library_javavm.mk
+++ b/stoc/Library_javavm.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_Library_use_udk_api,javavm))
 $(eval $(call gb_Library_use_libraries,javavm,\
     cppu \
     cppuhelper \
+    i18nlangtag \
     jvmaccess \
     jvmfwk \
     sal \
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index 87196d5..b27df6f 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -71,6 +71,7 @@
 #include <uno/current_context.hxx>
 #include <uno/environment.h>
 #include <jvmfwk/framework.hxx>
+#include <i18nlangtag/languagetag.hxx>
 #include "jni.h"
 
 #include <stack>
@@ -368,28 +369,25 @@ void getDefaultLocaleFromConfig(
     // read locale
     css::uno::Reference<css::registry::XRegistryKey> locale = xRegistryRootKey->openKey("L10N/ooLocale");
     if(locale.is() && !locale->getStringValue().isEmpty()) {
+        LanguageTag aLanguageTag( locale->getStringValue());
         OUString language;
+        OUString script;
         OUString country;
+        // Java knows nothing but plain old ISO language and country codes.
+        aLanguageTag.getIsoLanguageScriptCountry( language, script, country);
 
-        sal_Int32 index = locale->getStringValue().indexOf((sal_Unicode) '-');
+        if(!language.isEmpty()) {
+            OUString prop = "user.language="
+                          + language;
 
-        if(index >= 0) {
-            language = locale->getStringValue().copy(0, index);
-            country = locale->getStringValue().copy(index + 1);
-
-            if(!language.isEmpty()) {
-                OUString prop = "user.language="
-                              + language;
-
-                pjvm->pushProp(prop);
-            }
+            pjvm->pushProp(prop);
+        }
 
-            if(!country.isEmpty()) {
-                OUString prop = "user.country="
-                              + country;
+        if(!country.isEmpty()) {
+            OUString prop = "user.country="
+                          + country;
 
-                pjvm->pushProp(prop);
-            }
+            pjvm->pushProp(prop);
         }
     }
 


More information about the Libreoffice-commits mailing list