Capitalize TZ display name strings
Capitalize Settings UI time zone display name strings for languanges like Polish for standalone locations like summaries and lists. The motivating example case is the string for "Coordinated Universal Time" in Polish, which is not capitalized in CLDR, as they capitalize for the middle of sentences by default. In English, Coordinated Universal Time is already capitalized, but the Polish string is not. With this commit all "display name"-like strings have been capitalized (region names, exemplar locations, time zone names like "Coordinated Universal Time" and "British Summer Time") for completeness. For the Polish case, many are already capitalized, but capitalizing the first letter is therefore a no-op. The "GMT+xx:xx"-style strings have not been changed. Bug: 190109975 Test: Visual inspection in English and Polish of UTC, United States, Russia in the time zone picker and the date & time screen on mobile Change-Id: I57d915ac1e30e22cc05e605fcb7d46b102fa8ce1
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.datetime.timezone;
|
||||
|
||||
import static com.android.settingslib.datetime.ZoneGetter.capitalizeForStandaloneDisplay;
|
||||
|
||||
import android.icu.text.TimeZoneFormat;
|
||||
import android.icu.text.TimeZoneNames;
|
||||
import android.icu.util.TimeZone;
|
||||
@@ -152,19 +154,29 @@ public class TimeZoneInfo {
|
||||
String canonicalZoneId = getCanonicalZoneId(timeZone);
|
||||
final TimeZoneNames timeZoneNames = mTimeZoneFormat.getTimeZoneNames();
|
||||
final java.util.TimeZone javaTimeZone = toJavaTimeZone(canonicalZoneId);
|
||||
final CharSequence gmtOffset = ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale,
|
||||
javaTimeZone, mNow);
|
||||
final CharSequence gmtOffset =
|
||||
ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale, javaTimeZone, mNow);
|
||||
return new TimeZoneInfo.Builder(timeZone)
|
||||
.setGenericName(timeZoneNames.getDisplayName(canonicalZoneId,
|
||||
TimeZoneNames.NameType.LONG_GENERIC, mNow.getTime()))
|
||||
.setStandardName(timeZoneNames.getDisplayName(canonicalZoneId,
|
||||
TimeZoneNames.NameType.LONG_STANDARD, mNow.getTime()))
|
||||
.setDaylightName(timeZoneNames.getDisplayName(canonicalZoneId,
|
||||
TimeZoneNames.NameType.LONG_DAYLIGHT, mNow.getTime()))
|
||||
.setExemplarLocation(timeZoneNames.getExemplarLocationName(canonicalZoneId))
|
||||
.setGenericName(getTzNameForListDisplay(mLocale, timeZoneNames,
|
||||
canonicalZoneId, mNow, TimeZoneNames.NameType.LONG_GENERIC))
|
||||
.setStandardName(getTzNameForListDisplay(mLocale, timeZoneNames,
|
||||
canonicalZoneId, mNow, TimeZoneNames.NameType.LONG_STANDARD))
|
||||
.setDaylightName(getTzNameForListDisplay(mLocale, timeZoneNames,
|
||||
canonicalZoneId, mNow, TimeZoneNames.NameType.LONG_DAYLIGHT))
|
||||
.setExemplarLocation(capitalizeForStandaloneDisplay(mLocale,
|
||||
timeZoneNames.getExemplarLocationName(canonicalZoneId)))
|
||||
.setGmtOffset(gmtOffset)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static String getTzNameForListDisplay(
|
||||
Locale locale, TimeZoneNames timeZoneNames, String canonicalZoneId, Date now,
|
||||
TimeZoneNames.NameType nameType) {
|
||||
long nowEpochMillis = now.getTime();
|
||||
String displayName = timeZoneNames.getDisplayName(
|
||||
canonicalZoneId, nameType, nowEpochMillis);
|
||||
return capitalizeForStandaloneDisplay(locale, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
/* package-private */ java.util.TimeZone getJavaTimeZone() {
|
||||
|
Reference in New Issue
Block a user