mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 02:17:34 +09:00
Issue #1969 - Implement Intl.RelativeTimeFormat.
Based on Mozilla bugs 1270140, 1504656, 1483545, and 1504334. Took note of Mozilla bug 1379222 which changed GetPrototypeFromCallableConstructor to GetPrototypeFromBuiltinConstructor. There are many other changes I did myself since the initial implementation by Mozilla wouldn't work with this codebase.
This commit is contained in:
parent
c090dd7ce8
commit
3e6cbc6af3
13 changed files with 669 additions and 20 deletions
|
|
@ -0,0 +1,45 @@
|
|||
Workaround for https://unicode-org.atlassian.net/browse/ICU-20253
|
||||
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1504656
|
||||
|
||||
diff --git a/intl/icu/source/i18n/reldatefmt.cpp b/intl/icu/source/i18n/reldatefmt.cpp
|
||||
--- a/intl/icu/source/i18n/reldatefmt.cpp
|
||||
+++ b/intl/icu/source/i18n/reldatefmt.cpp
|
||||
@@ -157,24 +157,30 @@ const UnicodeString& RelativeDateTimeCac
|
||||
}
|
||||
|
||||
// Use fallback cache for SimpleFormatter relativeUnits.
|
||||
const SimpleFormatter* RelativeDateTimeCacheData::getRelativeDateTimeUnitFormatter(
|
||||
int32_t fStyle,
|
||||
URelativeDateTimeUnit unit,
|
||||
int32_t pastFutureIndex,
|
||||
int32_t pluralUnit) const {
|
||||
- int32_t style = fStyle;
|
||||
- do {
|
||||
- if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
- return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
+ while (true) {
|
||||
+ int32_t style = fStyle;
|
||||
+ do {
|
||||
+ if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
+ return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
+ }
|
||||
+ style = fallBackCache[style];
|
||||
+ } while (style != -1);
|
||||
+
|
||||
+ if (pluralUnit == StandardPlural::OTHER) {
|
||||
+ return nullptr; // No formatter found.
|
||||
}
|
||||
- style = fallBackCache[style];
|
||||
- } while (style != -1);
|
||||
- return nullptr; // No formatter found.
|
||||
+ pluralUnit = StandardPlural::OTHER;
|
||||
+ }
|
||||
}
|
||||
|
||||
static UBool getStringWithFallback(
|
||||
const UResourceBundle *resource,
|
||||
const char *key,
|
||||
UnicodeString &result,
|
||||
UErrorCode &status) {
|
||||
int32_t len = 0;
|
||||
Loading…
Add table
Add a link
Reference in a new issue