Added en-US locale to preferences.

Also changed the way locales are loaded. Now it deals well with language
codes that are followed by country codes (e.g. "en-US" rather than just
"en").
This commit is contained in:
Peter Serwylo 2015-04-11 23:04:37 +10:00
parent 04a05e3c52
commit 7f929f96a1
2 changed files with 8 additions and 2 deletions

View File

@ -39,6 +39,7 @@
<item>de</item> <item>de</item>
<item>el</item> <item>el</item>
<item>en-rGB</item> <item>en-rGB</item>
<item>en-US</item>
<item>eo</item> <item>eo</item>
<item>es</item> <item>es</item>
<item>eu</item> <item>eu</item>

View File

@ -7,6 +7,7 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.Nullable;
import android.support.v4.preference.PreferenceFragment; import android.support.v4.preference.PreferenceFragment;
import android.text.TextUtils; import android.text.TextUtils;
@ -299,8 +300,12 @@ public class PreferencesFragment extends PreferenceFragment
String[] langNames = new String[langValues.length]; String[] langNames = new String[langValues.length];
langNames[0] = getString(R.string.pref_language_default); langNames[0] = getString(R.string.pref_language_default);
for (int i = 1; i < langValues.length; i++) { for (int i = 1; i < langValues.length; i++) {
Locale appLoc = new Locale(langValues[i]); try {
langNames[i] = appLoc.getDisplayLanguage(appLoc); final Locale appLoc = Locale.forLanguageTag(langValues[i]);
langNames[i] = appLoc.getDisplayName(appLoc);
} catch (Exception e) {
langNames[i] = langValues[i];
}
} }
pref.setEntries(langNames); pref.setEntries(langNames);
} }