Update translations

This commit is contained in:
topjohnwu 2017-08-27 01:38:05 +08:00
parent 977b6d9f67
commit 1ce1a94a35
3 changed files with 16 additions and 7 deletions

View File

@ -87,6 +87,7 @@ public class MagiskManager extends Application {
public int suResponseType;
public int suNotificationType;
public int suNamespaceMode;
public String localeConfig;
// Global resources
public SharedPreferences prefs;
@ -125,11 +126,11 @@ public class MagiskManager extends Application {
}
public void setLocale() {
String localeTag = prefs.getString("locale", "");
if (localeTag.isEmpty()) {
localeConfig = prefs.getString("locale", "");
if (localeConfig.isEmpty()) {
locale = defaultLocale;
} else {
locale = Locale.forLanguageTag(localeTag);
locale = Locale.forLanguageTag(localeConfig);
}
Resources res = getBaseContext().getResources();
Configuration config = new Configuration(res.getConfiguration());
@ -192,6 +193,7 @@ public class MagiskManager extends Application {
.putString("multiuser_mode", String.valueOf(multiuserMode))
.putString("mnt_ns", String.valueOf(suNamespaceMode))
.putString("busybox_version", BUSYBOX_VERSION)
.putString("locale", localeConfig)
.apply();
// Add busybox to PATH

View File

@ -266,21 +266,23 @@ public class Utils {
HashSet<String> set = new HashSet<>();
Locale locale;
int compareId = R.string.download_file_error;
// Add default locale
locales.add(Locale.ENGLISH);
set.add(getLocaleString(context, Locale.ENGLISH, R.string.download));
set.add(getLocaleString(context, Locale.ENGLISH, compareId));
// Add some special locales
locales.add(Locale.TAIWAN);
set.add(getLocaleString(context, Locale.TAIWAN, R.string.download));
set.add(getLocaleString(context, Locale.TAIWAN, compareId));
locale = new Locale("pt", "BR");
locales.add(locale);
set.add(getLocaleString(context, locale, R.string.download));
set.add(getLocaleString(context, locale, compareId));
// Other locales
for (String s : context.getAssets().getLocales()) {
locale = Locale.forLanguageTag(s);
if (set.add(getLocaleString(context, locale, R.string.download))) {
if (set.add(getLocaleString(context, locale, compareId))) {
locales.add(locale);
}
}

View File

@ -221,5 +221,10 @@
<string name="magisk_updates">Magisk 更新</string>
<string name="system_default">(系統預設)</string>
<string name="language">語言</string>
<string name="flashing">正在刷入</string>
<string name="hide_manager_toast">正在隱藏 Magisk Manager…</string>
<string name="hide_manager_fail_toast">隱藏 Magisk Manager 失敗</string>
<string name="settings_hide_manager_title">隱藏 Magisk Manager</string>
<string name="settings_hide_manager_summary">暫時隱藏 Magisk Manager。\n這會新增一個新的 app 叫做 Unhide Magisk Manager</string>
</resources>