am 8d4faa9e
: Merge change 7977 into donut
Merge commit '8d4faa9ec3e29695b8d5d039bc8ac12d9bd655a8' * commit '8d4faa9ec3e29695b8d5d039bc8ac12d9bd655a8': Add a way to override the display names for locales in the locale picker.
This commit is contained in:
committed by
Android Git Automerger
commit
c4bd101e21
@@ -255,4 +255,17 @@
|
|||||||
<item>2</item>
|
<item>2</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Locales in this list are displayed with the corresponding
|
||||||
|
name from special_locale_names instead of using the name
|
||||||
|
from Locale.getDisplayName(). -->
|
||||||
|
<string-array translatable="false" name="special_locale_codes">
|
||||||
|
<item>zh_CN</item>
|
||||||
|
<item>zh_TW</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array translatable="false" name="special_locale_names">
|
||||||
|
<item>中文(简体)</item>
|
||||||
|
<item>中文 (繁體)</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -39,6 +39,8 @@ public class LocalePicker extends ListActivity {
|
|||||||
private static final String TAG = "LocalePicker";
|
private static final String TAG = "LocalePicker";
|
||||||
|
|
||||||
Loc[] mLocales;
|
Loc[] mLocales;
|
||||||
|
String[] mSpecialLocaleCodes;
|
||||||
|
String[] mSpecialLocaleNames;
|
||||||
|
|
||||||
private static class Loc implements Comparable {
|
private static class Loc implements Comparable {
|
||||||
static Collator sCollator = Collator.getInstance();
|
static Collator sCollator = Collator.getInstance();
|
||||||
@@ -70,6 +72,9 @@ public class LocalePicker extends ListActivity {
|
|||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
setContentView(getContentView());
|
setContentView(getContentView());
|
||||||
|
|
||||||
|
mSpecialLocaleCodes = getResources().getStringArray(R.array.special_locale_codes);
|
||||||
|
mSpecialLocaleNames = getResources().getStringArray(R.array.special_locale_names);
|
||||||
|
|
||||||
String[] locales = getAssets().getLocales();
|
String[] locales = getAssets().getLocales();
|
||||||
Arrays.sort(locales);
|
Arrays.sort(locales);
|
||||||
|
|
||||||
@@ -98,15 +103,13 @@ public class LocalePicker extends ListActivity {
|
|||||||
language)) {
|
language)) {
|
||||||
Log.v(TAG, "backing up and fixing "+
|
Log.v(TAG, "backing up and fixing "+
|
||||||
preprocess[finalSize-1].label+" to "+
|
preprocess[finalSize-1].label+" to "+
|
||||||
preprocess[finalSize-1].locale.
|
getDisplayName(preprocess[finalSize-1].locale));
|
||||||
getDisplayName(l));
|
|
||||||
preprocess[finalSize-1].label = toTitleCase(
|
preprocess[finalSize-1].label = toTitleCase(
|
||||||
preprocess[finalSize-1].
|
getDisplayName(preprocess[finalSize-1].locale));
|
||||||
locale.getDisplayName(l));
|
|
||||||
Log.v(TAG, " and adding "+
|
Log.v(TAG, " and adding "+
|
||||||
toTitleCase(l.getDisplayName(l)));
|
toTitleCase(getDisplayName(l)));
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
new Loc(toTitleCase(l.getDisplayName(l)), l);
|
new Loc(toTitleCase(getDisplayName(l)), l);
|
||||||
} else {
|
} else {
|
||||||
String displayName;
|
String displayName;
|
||||||
if (s.equals("zz_ZZ")) {
|
if (s.equals("zz_ZZ")) {
|
||||||
@@ -140,6 +143,18 @@ public class LocalePicker extends ListActivity {
|
|||||||
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDisplayName(Locale l) {
|
||||||
|
String code = l.toString();
|
||||||
|
|
||||||
|
for (int i = 0; i < mSpecialLocaleCodes.length; i++) {
|
||||||
|
if (mSpecialLocaleCodes[i].equals(code)) {
|
||||||
|
return mSpecialLocaleNames[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l.getDisplayName(l);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Reference in New Issue
Block a user