You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2022/11/16 15:57:46 UTC

[hop] branch master updated: LanguageChoice not working when default local supports multiple variants or with script code(ISO 15924)

This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 4724a2cf5d LanguageChoice not working when default local supports multiple variants or with script code(ISO 15924)
     new 0809e24430 Merge pull request #1798 from shlxue/master
4724a2cf5d is described below

commit 4724a2cf5d18c1da035b578493945a207cc29644
Author: Shl Xue <xu...@gmail.com>
AuthorDate: Wed Nov 16 22:44:23 2022 +0800

    LanguageChoice not working when default local supports multiple variants or with script code(ISO 15924)
---
 core/src/main/java/org/apache/hop/i18n/LanguageChoice.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/core/src/main/java/org/apache/hop/i18n/LanguageChoice.java b/core/src/main/java/org/apache/hop/i18n/LanguageChoice.java
index 16ec589abb..47beb9a3cf 100644
--- a/core/src/main/java/org/apache/hop/i18n/LanguageChoice.java
+++ b/core/src/main/java/org/apache/hop/i18n/LanguageChoice.java
@@ -20,6 +20,7 @@ package org.apache.hop.i18n;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.config.HopConfig;
 import org.apache.hop.core.util.EnvUtil;
+import org.apache.hop.core.util.StringUtil;
 
 import java.util.Locale;
 
@@ -35,6 +36,10 @@ public class LanguageChoice {
     if (defaultLocaleString == null) {
       defaultLocale = Locale.getDefault();
       // check if in language list and if beta language
+      if (!StringUtil.isEmpty(defaultLocale.getVariant())
+          || !StringUtil.isEmpty(defaultLocale.getScript())) {
+        defaultLocale = new Locale(defaultLocale.getLanguage(), defaultLocale.getCountry());
+      }
       int localeIdx = Const.indexOfString(defaultLocale.toString(), GlobalMessages.localeCodes);
       if (localeIdx < 0 || GlobalMessages.localeBetaStatus[localeIdx].equals("Y")) {
         // if not in language list or it is a beta language set to en-US