@@ -29,6 +29,7 @@ namespace v8 {
29
29
namespace internal {
30
30
31
31
namespace {
32
+ #if U_ICU_VERSION_MAJOR_NUM < 68
32
33
const char * kStandard = " standard" ;
33
34
const char * kOr = " or" ;
34
35
const char * kUnit = " unit" ;
@@ -41,8 +42,24 @@ const char* kUnitNarrow = "unit-narrow";
41
42
42
43
const char * GetIcuStyleString (JSListFormat::Style style,
43
44
JSListFormat::Type type) {
45
+ #else
46
+ UListFormatterWidth GetIcuWidth (JSListFormat::Style style) {
47
+ switch (style) {
48
+ case JSListFormat::Style::LONG:
49
+ return ULISTFMT_WIDTH_WIDE;
50
+ case JSListFormat::Style::SHORT:
51
+ return ULISTFMT_WIDTH_SHORT;
52
+ case JSListFormat::Style::NARROW:
53
+ return ULISTFMT_WIDTH_NARROW;
54
+ }
55
+ UNREACHABLE ();
56
+ }
57
+
58
+ UListFormatterType GetIcuType (JSListFormat::Type type) {
59
+ #endif
44
60
switch (type) {
45
61
case JSListFormat::Type::CONJUNCTION:
62
+ #if U_ICU_VERSION_MAJOR_NUM < 68
46
63
switch (style) {
47
64
case JSListFormat::Style::LONG:
48
65
return kStandard ;
@@ -51,7 +68,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
51
68
case JSListFormat::Style::NARROW:
52
69
return kStandardNarrow ;
53
70
}
71
+ #else
72
+ return ULISTFMT_TYPE_AND;
73
+ #endif
54
74
case JSListFormat::Type::DISJUNCTION:
75
+ #if U_ICU_VERSION_MAJOR_NUM < 68
55
76
switch (style) {
56
77
case JSListFormat::Style::LONG:
57
78
return kOr ;
@@ -60,7 +81,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
60
81
case JSListFormat::Style::NARROW:
61
82
return kOrNarrow ;
62
83
}
84
+ #else
85
+ return ULISTFMT_TYPE_OR;
86
+ #endif
63
87
case JSListFormat::Type::UNIT:
88
+ #if U_ICU_VERSION_MAJOR_NUM < 68
64
89
switch (style) {
65
90
case JSListFormat::Style::LONG:
66
91
return kUnit ;
@@ -69,6 +94,9 @@ const char* GetIcuStyleString(JSListFormat::Style style,
69
94
case JSListFormat::Style::NARROW:
70
95
return kUnitNarrow ;
71
96
}
97
+ #else
98
+ return ULISTFMT_TYPE_UNITS;
99
+ #endif
72
100
}
73
101
UNREACHABLE ();
74
102
}
@@ -170,7 +198,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
170
198
icu::Locale icu_locale = r.icu_locale ;
171
199
UErrorCode status = U_ZERO_ERROR;
172
200
icu::ListFormatter* formatter = icu::ListFormatter::createInstance (
201
+ #if U_ICU_VERSION_MAJOR_NUM < 68
173
202
icu_locale, GetIcuStyleString (style_enum, type_enum), status);
203
+ #else
204
+ icu_locale, GetIcuType (type_enum), GetIcuWidth (style_enum), status);
205
+ #endif
174
206
if (U_FAILURE (status)) {
175
207
delete formatter;
176
208
FATAL (" Failed to create ICU list formatter, are ICU data files missing?" );
0 commit comments