Commit 90bc96d7 authored by Michael Chan's avatar Michael Chan Committed by Android Git Automerger
Browse files

am fa1c198c: Merge "Embedded country names in the app for ones not in framework" into jb-mr2-dev

* commit 'fa1c198c':
  Embedded country names in the app for ones not in framework
parents 0044d6e2 fa1c198c
......@@ -124,4 +124,29 @@
<item>"Brasilia - Pará"</item>
</string-array>
</resources>
\ No newline at end of file
<!--
Country codes
The order should match the entries in backup_country_names
ALWAYS ADD NEW ENTRIES AT THE END. Othewise the entries after the insertion point will
not match for languages that didn't get the translations.
-->
<string-array name="backup_country_codes" translatable="false">
<item>"SX"</item>
<item>"BQ"</item>
<item>"CW"</item>
<item>"SS"</item>
</string-array>
<!--
Display strings for country names. Used only if framework doesn't have translated
country names. The order should match the entries in backup_country_codes
ALWAYS ADD NEW ENTRIES AT THE END. Othewise the array will not be the same size until
all the translations are available. [CHAR LIMIT=32]
-->
<string-array name="backup_country_names">
<item>"Sint Maarten"</item>
<item>"Caribbean Netherlands"</item>
<item>"Curaçao"</item>
<item>"South Sudan"</item>
</string-array>
</resources>
......@@ -394,8 +394,7 @@ public class TimeZoneData {
// name
String country = mCountryCodeToNameMap.get(countryCode);
if (country == null) {
country = new Locale(lang, countryCode)
.getDisplayCountry(Locale.getDefault());
country = getCountryNames(lang, countryCode);
mCountryCodeToNameMap.put(countryCode, country);
}
......@@ -465,6 +464,38 @@ public class TimeZoneData {
return processedTimeZones;
}
@SuppressWarnings("unused")
private static Locale mBackupCountryLocale;
private static String[] mBackupCountryCodes;
private static String[] mBackupCountryNames;
private String getCountryNames(String lang, String countryCode) {
final Locale defaultLocale = Locale.getDefault();
String countryDisplayName = new Locale(lang, countryCode).getDisplayCountry(defaultLocale);
if (!countryCode.equals(countryDisplayName)) {
return countryDisplayName;
}
if (mBackupCountryCodes == null || !defaultLocale.equals(mBackupCountryLocale)) {
mBackupCountryLocale = defaultLocale;
mBackupCountryCodes = mContext.getResources().getStringArray(
R.array.backup_country_codes);
mBackupCountryNames = mContext.getResources().getStringArray(
R.array.backup_country_names);
}
int length = Math.min(mBackupCountryCodes.length, mBackupCountryNames.length);
for (int i = 0; i < length; i++) {
if (mBackupCountryCodes[i].equals(countryCode)) {
return mBackupCountryNames[i];
}
}
return countryCode;
}
private int getIdenticalTimeZoneInTheCountry(TimeZoneInfo timeZoneInfo) {
int idx = 0;
for (TimeZoneInfo tzi : mTimeZones) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment