forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1636984 - Part 1: Add patches to workaround ICU/CLDR issues with …
…display names and append items. r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D74681
- Loading branch information
Showing
4 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Handle "alias" entries in DateTimePatternGenerator::AppendItemNamesSink. | ||
# | ||
# ICU bug: https://unicode-org.atlassian.net/browse/ICU-20992 | ||
|
||
diff --git a/intl/icu/source/i18n/dtptngen.cpp b/intl/icu/source/i18n/dtptngen.cpp | ||
--- a/intl/icu/source/i18n/dtptngen.cpp | ||
+++ b/intl/icu/source/i18n/dtptngen.cpp | ||
@@ -956,16 +956,25 @@ struct DateTimePatternGenerator::AppendI | ||
virtual void put(const char *key, ResourceValue &value, UBool /*noFallback*/, | ||
UErrorCode &errorCode) { | ||
ResourceTable itemsTable = value.getTable(errorCode); | ||
if (U_FAILURE(errorCode)) { return; } | ||
for (int32_t i = 0; itemsTable.getKeyAndValue(i, key, value); ++i) { | ||
UDateTimePGDisplayWidth width; | ||
UDateTimePatternField field = dtpg.getFieldAndWidthIndices(key, &width); | ||
if (field == UDATPG_FIELD_COUNT) { continue; } | ||
+ | ||
+ UResType type = value.getType(); | ||
+ U_ASSERT(type == URES_TABLE || type == URES_ALIAS); | ||
+ | ||
+ // TODO: Implement support for alias types. | ||
+ if (type == URES_ALIAS) { | ||
+ continue; | ||
+ } | ||
+ | ||
ResourceTable detailsTable = value.getTable(errorCode); | ||
if (U_FAILURE(errorCode)) { return; } | ||
for (int32_t j = 0; detailsTable.getKeyAndValue(j, key, value); ++j) { | ||
if (uprv_strcmp(key, "dn") != 0) { continue; } | ||
const UnicodeString& valueStr = value.getUnicodeString(errorCode); | ||
if (dtpg.getFieldDisplayName(field,width).isEmpty() && !valueStr.isEmpty()) { | ||
dtpg.setFieldDisplayName(field,width,valueStr); | ||
} |
86 changes: 86 additions & 0 deletions
86
intl/icu-patches/bug-1636984-append-item-dayperiod-fractional-seconds.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Add <appendItem> entries for "DayPeriod" and "FractionalSeconds" to avoid the | ||
# "├ ┤" parentheses from ICU and instead use the normal "( )" parentheses. | ||
# | ||
# CLDR bug: https://unicode-org.atlassian.net/browse/CLDR-13184 | ||
|
||
diff --git a/intl/icu/source/data/locales/root.txt b/intl/icu/source/data/locales/root.txt | ||
--- a/intl/icu/source/data/locales/root.txt | ||
+++ b/intl/icu/source/data/locales/root.txt | ||
@@ -213,17 +213,19 @@ root{ | ||
} | ||
NoonMarker:alias{"/LOCALE/calendar/gregorian/NoonMarker"} | ||
NoonMarkerNarrow:alias{"/LOCALE/calendar/gregorian/NoonMarkerNarrow"} | ||
appendItems{ | ||
Day{"{0} ({2}: {1})"} | ||
+ DayPeriod{"{0} ({2}: {1})"} | ||
Day-Of-Week{"{0} {1}"} | ||
Era{"{1} {0}"} | ||
Hour{"{0} ({2}: {1})"} | ||
Minute{"{0} ({2}: {1})"} | ||
Month{"{0} ({2}: {1})"} | ||
Quarter{"{0} ({2}: {1})"} | ||
Second{"{0} ({2}: {1})"} | ||
+ FractionalSecond{"{0} ({2}: {1})"} | ||
Timezone{"{0} {1}"} | ||
Week{"{0} ({2}: {1})"} | ||
Year{"{1} {0}"} | ||
} | ||
availableFormats{ | ||
@@ -749,17 +751,19 @@ root{ | ||
} | ||
NoonMarker:alias{"/LOCALE/calendar/gregorian/NoonMarker"} | ||
NoonMarkerNarrow:alias{"/LOCALE/calendar/gregorian/NoonMarkerNarrow"} | ||
appendItems{ | ||
Day{"{0} ({2}: {1})"} | ||
+ DayPeriod{"{0} ({2}: {1})"} | ||
Day-Of-Week{"{0} {1}"} | ||
Era{"{1} {0}"} | ||
Hour{"{0} ({2}: {1})"} | ||
Minute{"{0} ({2}: {1})"} | ||
Month{"{0} ({2}: {1})"} | ||
Quarter{"{0} ({2}: {1})"} | ||
Second{"{0} ({2}: {1})"} | ||
+ FractionalSecond{"{0} ({2}: {1})"} | ||
Timezone{"{0} {1}"} | ||
Week{"{0} ({2}: {1})"} | ||
Year{"{1} {0}"} | ||
} | ||
availableFormats{ | ||
@@ -1018,17 +1022,19 @@ root{ | ||
"{1} {0}", | ||
"{1} {0}", | ||
} | ||
appendItems{ | ||
Day{"{0} ({2}: {1})"} | ||
+ DayPeriod{"{0} ({2}: {1})"} | ||
Day-Of-Week{"{0} {1}"} | ||
Era{"{1} {0}"} | ||
Hour{"{0} ({2}: {1})"} | ||
Minute{"{0} ({2}: {1})"} | ||
Month{"{0} ({2}: {1})"} | ||
Quarter{"{0} ({2}: {1})"} | ||
Second{"{0} ({2}: {1})"} | ||
+ FractionalSecond{"{0} ({2}: {1})"} | ||
Timezone{"{0} {1}"} | ||
Week{"{0} ({2}: {1})"} | ||
Year{"{1} {0}"} | ||
} | ||
availableFormats{ | ||
diff --git a/intl/icu/source/i18n/dtptngen.cpp b/intl/icu/source/i18n/dtptngen.cpp | ||
--- a/intl/icu/source/i18n/dtptngen.cpp | ||
+++ b/intl/icu/source/i18n/dtptngen.cpp | ||
@@ -257,12 +257,12 @@ static const dtTypeElem dtTypes[] = { | ||
{0, UDATPG_FIELD_COUNT, 0, 0, 0} , // last row of dtTypes[] | ||
}; | ||
|
||
static const char* const CLDR_FIELD_APPEND[] = { | ||
"Era", "Year", "Quarter", "Month", "Week", "*", "Day-Of-Week", | ||
- "*", "*", "Day", "*", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J | ||
- "Hour", "Minute", "Second", "*", "Timezone" | ||
+ "*", "*", "Day", "DayPeriod", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J | ||
+ "Hour", "Minute", "Second", "FractionalSecond", "Timezone" | ||
}; | ||
|
||
static const char* const CLDR_FIELD_NAME[UDATPG_FIELD_COUNT] = { | ||
"era", "year", "quarter", "month", "week", "weekOfMonth", "weekday", | ||
"dayOfYear", "weekdayOfMonth", "day", "dayperiod", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J |
39 changes: 39 additions & 0 deletions
39
intl/icu-patches/bug-1636984-display-name-fractional-seconds.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Give fractional seconds a more useful display name than "F14". | ||
# | ||
# CLDR bug: https://unicode-org.atlassian.net/browse/CLDR-13623 | ||
|
||
diff --git a/intl/icu/source/data/locales/root.txt b/intl/icu/source/data/locales/root.txt | ||
--- a/intl/icu/source/data/locales/root.txt | ||
+++ b/intl/icu/source/data/locales/root.txt | ||
@@ -2527,10 +2527,15 @@ root{ | ||
zone{ | ||
dn{"Zone"} | ||
} | ||
zone-narrow:alias{"/LOCALE/fields/zone-short"} | ||
zone-short:alias{"/LOCALE/fields/zone"} | ||
+ fractionalSecond{ | ||
+ dn{"Fractional Second"} | ||
+ } | ||
+ fractionalSecond-narrow:alias{"/LOCALE/fields/fractionalSecond-short"} | ||
+ fractionalSecond-short:alias{"/LOCALE/fields/fractionalSecond"} | ||
} | ||
layout{ | ||
characters{"left-to-right"} | ||
lines{"top-to-bottom"} | ||
} | ||
diff --git a/intl/icu/source/i18n/dtptngen.cpp b/intl/icu/source/i18n/dtptngen.cpp | ||
--- a/intl/icu/source/i18n/dtptngen.cpp | ||
+++ b/intl/icu/source/i18n/dtptngen.cpp | ||
@@ -264,11 +264,11 @@ static const char* const CLDR_FIELD_APPE | ||
}; | ||
|
||
static const char* const CLDR_FIELD_NAME[UDATPG_FIELD_COUNT] = { | ||
"era", "year", "quarter", "month", "week", "weekOfMonth", "weekday", | ||
"dayOfYear", "weekdayOfMonth", "day", "dayperiod", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J | ||
- "hour", "minute", "second", "*", "zone" | ||
+ "hour", "minute", "second", "fractionalSecond", "zone" | ||
}; | ||
|
||
static const char* const CLDR_FIELD_WIDTH[] = { // [UDATPG_WIDTH_COUNT] | ||
"", "-short", "-narrow" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters