1 | // @needsAudit
|
2 | export type Localization = {
|
3 | /**
|
4 | * Three-character ISO 4217 currency code. Returns `null` on web.
|
5 | * @example
|
6 | * `'USD'`, `'EUR'`, `'CNY'`, `null`
|
7 | */
|
8 | currency: string | null;
|
9 | /**
|
10 | * Decimal separator used for formatting numbers.
|
11 | * @example
|
12 | * `','`, `'.'`
|
13 | */
|
14 | decimalSeparator: string;
|
15 | /**
|
16 | * Digit grouping separator used when formatting numbers larger than 1000.
|
17 | * @example
|
18 | * `'.'`, `''`, `','`
|
19 | */
|
20 | digitGroupingSeparator: string;
|
21 | /**
|
22 | * A list of all the supported language ISO codes.
|
23 | */
|
24 | isoCurrencyCodes: string[];
|
25 | /**
|
26 | * Boolean value that indicates whether the system uses the metric system.
|
27 | * On Android and web, this is inferred from the current region.
|
28 | */
|
29 | isMetric: boolean;
|
30 | /**
|
31 | * Returns if the system's language is written from Right-to-Left.
|
32 | * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).
|
33 | *
|
34 | * Returns `false` in Server Side Rendering (SSR) environments.
|
35 | */
|
36 | isRTL: boolean;
|
37 | /**
|
38 | * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
39 | * consisting of a two-character language code and optional script, region and variant codes.
|
40 | * @example
|
41 | * `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
42 | */
|
43 | locale: string;
|
44 | /**
|
45 | * List of all the native languages provided by the user settings.
|
46 | * These are returned in the order that the user defined in the device settings.
|
47 | * @example
|
48 | * `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
49 | */
|
50 | locales: string[];
|
51 | /**
|
52 | * The region code for your device that comes from the Region setting under Language & Region on iOS.
|
53 | * This value is always available on iOS, but might return `null` on Android or web.
|
54 | * @example
|
55 | * `'US'`, `'NZ'`, `null`
|
56 | */
|
57 | region: string | null;
|
58 | /**
|
59 | * The current time zone in display format.
|
60 | * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a
|
61 | * better estimation you could use the moment-timezone package but it will add significant bloat to
|
62 | * your website's bundle size.
|
63 | * @example
|
64 | * `'America/Los_Angeles'`
|
65 | */
|
66 | timezone: string;
|
67 | };
|
68 |
|
69 | export type Locale = {
|
70 | /**
|
71 | * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
|
72 | * @example
|
73 | * `'en-US'`, `'es-419'`, `'pl-PL'`.
|
74 | */
|
75 | languageTag: string;
|
76 | /**
|
77 | * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.
|
78 | * @example
|
79 | * `'en'`, `'es'`, `'pl'`.
|
80 | */
|
81 | languageCode: string | null;
|
82 | /**
|
83 | * The region code for your device that comes from the Region setting under Language & Region on iOS, Region settings on Android and is parsed from locale on Web (can be `null` on Web).
|
84 | */
|
85 | regionCode: string | null;
|
86 | /**
|
87 | * Currency code for the locale.
|
88 | * Is `null` on Web, use a table lookup based on region instead.
|
89 | * @example
|
90 | * `'USD'`, `'EUR'`, `'PLN'`.
|
91 | */
|
92 | currencyCode: string | null;
|
93 | /**
|
94 | * Currency symbol for the locale.
|
95 | * Is `null` on Web, use a table lookup based on region (if available) instead.
|
96 | * @example
|
97 | * `'$'`, `'€'`, `'zł'`.
|
98 | */
|
99 | currencySymbol: string | null;
|
100 | /**
|
101 | * Decimal separator used for formatting numbers with fractional parts.
|
102 | * @example
|
103 | * `'.'`, `','`.
|
104 | */
|
105 | decimalSeparator: string | null;
|
106 | /**
|
107 | * Digit grouping separator used for formatting large numbers.
|
108 | * @example
|
109 | * `'.'`, `','`.
|
110 | */
|
111 | digitGroupingSeparator: string | null;
|
112 | /**
|
113 | * Text direction for the locale. One of: `'ltr'`, `'rtl'`, but can also be `null` on some browsers without support for the [textInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/textInfo) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
114 | */
|
115 | textDirection: 'ltr' | 'rtl' | null;
|
116 | /**
|
117 | * The measurement system used in the locale.
|
118 | * Is `null` on Web, as user chosen measurement system is not exposed on the web and using locale to determine measurement systems is unreliable.
|
119 | * Ask for user preferences if possible.
|
120 | */
|
121 | measurementSystem: `metric` | `us` | `uk` | null;
|
122 | /**
|
123 | * The temperature unit used in the locale.
|
124 | * Returns `null` if the region code is unknown.
|
125 | */
|
126 | temperatureUnit: 'celsius' | 'fahrenheit' | null;
|
127 | };
|
128 |
|
129 | /**
|
130 | * An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.
|
131 | */
|
132 | export enum Weekday {
|
133 | SUNDAY = 1,
|
134 | MONDAY = 2,
|
135 | TUESDAY = 3,
|
136 | WEDNESDAY = 4,
|
137 | THURSDAY = 5,
|
138 | FRIDAY = 6,
|
139 | SATURDAY = 7,
|
140 | }
|
141 |
|
142 | /**
|
143 | * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
|
144 | * Gregorian calendar is aliased and can be referred to as both `CalendarIdentifier.GREGORIAN` and `CalendarIdentifier.GREGORY`.
|
145 | */
|
146 | export enum CalendarIdentifier {
|
147 | /** Thai Buddhist calendar */
|
148 | BUDDHIST = 'buddhist',
|
149 | /** Traditional Chinese calendar */
|
150 | CHINESE = 'chinese',
|
151 | /** Coptic calendar */
|
152 | COPTIC = 'coptic',
|
153 | /** Traditional Korean calendar */
|
154 | DANGI = 'dangi',
|
155 | /** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */
|
156 | ETHIOAA = 'ethioaa',
|
157 | /** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */
|
158 | ETHIOPIC = 'ethiopic',
|
159 | /** Gregorian calendar */
|
160 | GREGORY = 'gregory',
|
161 | /** Gregorian calendar (alias) */
|
162 | GREGORIAN = 'gregory',
|
163 | /** Traditional Hebrew calendar */
|
164 | HEBREW = 'hebrew',
|
165 | /** Indian calendar */
|
166 | INDIAN = 'indian',
|
167 | /** Islamic calendar */
|
168 | ISLAMIC = 'islamic',
|
169 | /** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */
|
170 | ISLAMIC_CIVIL = 'islamic-civil',
|
171 | /** Islamic calendar, Saudi Arabia sighting */
|
172 | ISLAMIC_RGSA = 'islamic-rgsa',
|
173 | /**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */
|
174 | ISLAMIC_TBLA = 'islamic-tbla',
|
175 | /** Islamic calendar, Umm al-Qura */
|
176 | ISLAMIC_UMALQURA = 'islamic-umalqura',
|
177 | /** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */
|
178 | ISO8601 = 'iso8601',
|
179 | /** Japanese imperial calendar */
|
180 | JAPANESE = 'japanese',
|
181 | /** Persian calendar */
|
182 | PERSIAN = 'persian',
|
183 | /** Civil (algorithmic) Arabic calendar */
|
184 | ROC = 'roc',
|
185 | }
|
186 |
|
187 | export type Calendar = {
|
188 | /**
|
189 | * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
|
190 | *
|
191 | * On Android is limited to one of device's [available calendar types](https://developer.android.com/reference/java/util/Calendar#getAvailableCalendarTypes()).
|
192 | *
|
193 | * On iOS uses [calendar identifiers](https://developer.apple.com/documentation/foundation/calendar/identifier), but maps them to the corresponding Unicode types, will also never contain `'dangi'` or `'islamic-rgsa'` due to it not being implemented on iOS.
|
194 | */
|
195 | calendar: CalendarIdentifier | null;
|
196 | /**
|
197 | * True when current device settings use 24-hour time format.
|
198 | * Can be null on some browsers that don't support the [hourCycle](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
199 | */
|
200 | uses24hourClock: boolean | null;
|
201 | /**
|
202 | * The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.
|
203 | * Can be null on some browsers that don't support the [weekInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/weekInfo) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
204 | * @example
|
205 | * `1`, `7`.
|
206 | */
|
207 | firstWeekday: Weekday | null;
|
208 | /**
|
209 | * Time zone for the calendar. Can be `null` on Web.
|
210 | * @example
|
211 | * `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.
|
212 | */
|
213 | timeZone: string | null;
|
214 | };
|