Add multi code lang support for translations
This commit is contained in:
parent
e16284c352
commit
6149ab57e7
|
@ -326,7 +326,17 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
|
||||
private static String getLanguageDisplayName(String langCode) {
|
||||
Locale english = new Locale("en");
|
||||
Locale translated = new Locale(langCode);
|
||||
|
||||
String[] multiCodeLang = langCode.split("-");
|
||||
String countryCode;
|
||||
if (langCode.contains("-")) {
|
||||
langCode = multiCodeLang[0];
|
||||
countryCode = multiCodeLang[1];
|
||||
} else {
|
||||
countryCode = "";
|
||||
}
|
||||
|
||||
Locale translated = new Locale(langCode, countryCode);
|
||||
return String.format(
|
||||
"%s (%s)",
|
||||
translated.getDisplayName(translated), translated.getDisplayName(english));
|
||||
|
|
|
@ -316,9 +316,18 @@ public class AppUtil {
|
|||
|
||||
public static void setAppLocale(Resources resource, String locCode) {
|
||||
|
||||
String[] multiCodeLang = locCode.split("-");
|
||||
String countryCode;
|
||||
if (locCode.contains("-")) {
|
||||
locCode = multiCodeLang[0];
|
||||
countryCode = multiCodeLang[1];
|
||||
} else {
|
||||
countryCode = "";
|
||||
}
|
||||
|
||||
DisplayMetrics dm = resource.getDisplayMetrics();
|
||||
Configuration config = resource.getConfiguration();
|
||||
config.setLocale(new Locale(locCode.toLowerCase()));
|
||||
config.setLocale(new Locale(locCode.toLowerCase(), countryCode));
|
||||
resource.updateConfiguration(config, dm);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue