Use correct language tags for script and regional language variants (#3716)

* Fix language tags so script and regional variants work correctly

* Adjust update_translations.sh language tags for script/regional variants

ACKs for top commit:
  @ripcurlx:
    ACK 089232716d
This commit is contained in:
Christoph Atteneder 2019-12-03 11:37:32 +01:00 committed by GitHub
commit d8e19c4e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 17 deletions

View file

@ -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,25 +112,17 @@ public class LanguageUtil {
}
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 {
Locale locale = Locale.forLanguageTag(code);
return locale.getDisplayName(locale);
}
}
public static boolean isDefaultLanguageRTL() {
return rtlLanguagesCodes.contains(LanguageUtil.getDefaultLanguageLocaleAsCode());

View file

@ -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