From 9d25041746b7b03eb8dee9d901de546562073245 Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 29 Nov 2019 11:29:21 +0900 Subject: [PATCH 1/2] Fix language tags so script and regional variants work correctly --- .../java/bisq/core/locale/LanguageUtil.java | 22 ++++++------------- ...erties => displayStrings_pt-br.properties} | 0 ...ties => displayStrings_zh-hans.properties} | 0 3 files changed, 7 insertions(+), 15 deletions(-) rename core/src/main/resources/i18n/{displayStrings_pt_BR.properties => displayStrings_pt-br.properties} (100%) rename core/src/main/resources/i18n/{displayStrings_zh.properties => displayStrings_zh-hans.properties} (100%) diff --git a/core/src/main/java/bisq/core/locale/LanguageUtil.java b/core/src/main/java/bisq/core/locale/LanguageUtil.java index 4f72b9e7faf..0aa6118251a 100644 --- a/core/src/main/java/bisq/core/locale/LanguageUtil.java +++ b/core/src/main/java/bisq/core/locale/LanguageUtil.java @@ -34,8 +34,8 @@ public class LanguageUtil { "el", // Greek "es", // Spanish "pt", // Portuguese - "pt_BR", // Brazilian Portuguese - "zh", // Chinese + "pt-BR", // Portuguese (Brazil) + "zh-Hans", // Chinese [Han Simplified] "ru", // Russian "fr", // French "vi", // Vietnamese @@ -44,7 +44,7 @@ public class LanguageUtil { "fa" // Persian /* // not translated yet - "sr", // Serbian + "sr-Latn-RS", // Serbian [Latin] (Serbia) "hu", // Hungarian "ro", // Romanian "tr" // Turkish @@ -112,24 +112,16 @@ public static String getDefaultLanguage() { } public static String getDefaultLanguageLocaleAsCode() { - return new Locale(LanguageUtil.getDefaultLanguage(), "").getLanguage(); + return new Locale(LanguageUtil.getDefaultLanguage()).getLanguage(); } public static String getEnglishLanguageLocaleCode() { - return new Locale(Locale.ENGLISH.getLanguage(), "").getLanguage(); + return new Locale(Locale.ENGLISH.getLanguage()).getLanguage(); } public static String getDisplayName(String code) { - Locale locale = new Locale(code.toUpperCase()); - if (locale.getLanguage().equals("sr")) { - // Serbia - // shows it in russian by default - return "Srpski"; - } else if (locale.getLanguage().equals("pt_br")) { - return "português (Brasil)"; - } else { - return locale.getDisplayName(locale); - } + Locale locale = Locale.forLanguageTag(code); + return locale.getDisplayName(locale); } public static boolean isDefaultLanguageRTL() { diff --git a/core/src/main/resources/i18n/displayStrings_pt_BR.properties b/core/src/main/resources/i18n/displayStrings_pt-br.properties similarity index 100% rename from core/src/main/resources/i18n/displayStrings_pt_BR.properties rename to core/src/main/resources/i18n/displayStrings_pt-br.properties diff --git a/core/src/main/resources/i18n/displayStrings_zh.properties b/core/src/main/resources/i18n/displayStrings_zh-hans.properties similarity index 100% rename from core/src/main/resources/i18n/displayStrings_zh.properties rename to core/src/main/resources/i18n/displayStrings_zh-hans.properties From 089232716d759fe93cf7d4b98b7b475eae2e2601 Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 29 Nov 2019 11:34:22 +0900 Subject: [PATCH 2/2] Adjust update_translations.sh language tags for script/regional variants --- core/update_translations.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/update_translations.sh b/core/update_translations.sh index 72117831f0a..8f9985110d4 100755 --- a/core/update_translations.sh +++ b/core/update_translations.sh @@ -12,11 +12,11 @@ mv "$translations/es.properties" "$i18n/displayStrings_es.properties" mv "$translations/ja.properties" "$i18n/displayStrings_ja.properties" mv "$translations/pt.properties" "$i18n/displayStrings_pt.properties" mv "$translations/ru.properties" "$i18n/displayStrings_ru.properties" -mv "$translations/zh_CN.properties" "$i18n/displayStrings_zh.properties" +mv "$translations/zh_CN.properties" "$i18n/displayStrings_zh-hans.properties" mv "$translations/vi.properties" "$i18n/displayStrings_vi.properties" mv "$translations/th_TH.properties" "$i18n/displayStrings_th.properties" mv "$translations/fa.properties" "$i18n/displayStrings_fa.properties" mv "$translations/fr.properties" "$i18n/displayStrings_fr.properties" -mv "$translations/pt_BR.properties" "$i18n/displayStrings_pt_BR.properties" +mv "$translations/pt_BR.properties" "$i18n/displayStrings_pt-br.properties" rm -rf $translations