UNPKG

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