-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intl.ts
102 lines (75 loc) · 2.49 KB
/
Intl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { Polyfill } from '../Polyfill';
abstract class IntlPolyfill extends Polyfill {
get packageURLs() {
return [`${this.packageBase}/polyfill.iife.js`];
}
}
export class GetCanonicalLocales extends IntlPolyfill {
packageName = '@formatjs/intl-getcanonicallocales';
detect = function () {
return window.Intl && 'getCanonicalLocales' in window.Intl;
};
}
export class Locale extends IntlPolyfill {
packageName = '@formatjs/intl-locale';
dependencies = [new GetCanonicalLocales()];
detect = function () {
return window.Intl && window.Intl.Locale instanceof Function;
};
}
export class PluralRules extends IntlPolyfill {
packageName = '@formatjs/intl-pluralrules';
dependencies = [new Locale()];
detect = function () {
return window.Intl && window.Intl.PluralRules instanceof Function;
};
}
export class DisplayNames extends IntlPolyfill {
packageName = '@formatjs/intl-displaynames';
dependencies = [new Locale()];
detect = function () {
return window.Intl && window.Intl.DisplayNames instanceof Function;
};
}
export class ListFormat extends IntlPolyfill {
packageName = '@formatjs/intl-listformat';
dependencies = [new Locale()];
detect = function () {
return window.Intl && 'ListFormat' in window.Intl;
};
}
export class Segmenter extends IntlPolyfill {
packageName = 'intl-segmenter-polyfill-rs-web';
get packageURLs() {
return [
`${this.packageBase}/intl_segmenter_polyfill_rs.js`,
`${this.packageBase}/intl_segmenter_polyfill_rs_bg.wasm`
];
}
detect = function () {
return window.Intl && 'Segmenter' in window.Intl;
};
}
export class NumberFormat extends IntlPolyfill {
packageName = '@formatjs/intl-numberformat';
dependencies = [new PluralRules()];
detect = function () {
return window.Intl && window.Intl.NumberFormat instanceof Function;
};
}
export class DateTimeFormat extends IntlPolyfill {
packageName = '@formatjs/intl-datetimeformat';
dependencies = [new NumberFormat()];
detect = function () {
return window.Intl && window.Intl.DateTimeFormat instanceof Function;
};
}
export class RelativeTimeFormat extends IntlPolyfill {
packageName = '@formatjs/intl-relativetimeformat';
dependencies = [new NumberFormat()];
detect = function () {
return (
window.Intl && window.Intl.RelativeTimeFormat instanceof Function
);
};
}