1// @needsAudit
2export type Localization = {
3  /**
4   * Three-character ISO 4217 currency code. Returns `null` on web.
5   *
6   * @example `'USD'`, `'EUR'`, `'CNY'`, `null`
7   */
8  currency: string | null;
9  /**
10   * Decimal separator used for formatting numbers.
11   *
12   * @example `','`, `'.'`
13   */
14  decimalSeparator: string;
15  /**
16   * Digit grouping separator used when formatting numbers larger than 1000.
17   *
18   * @example `'.'`, `''`, `','`
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   *
41   * @example `'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   *
48   * @example `['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   *
55   * @example `'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   *
64   * @example `'America/Los_Angeles'`
65   */
66  timezone: string;
67};
68
69export type Locale = {
70  /**
71   * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
72   * @example `'en-US'`, `'es-419'`, `'pl-PL'`.
73   */
74  languageTag: string;
75  /**
76   * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.
77   * @example `'en'`, `'es'`, `'pl'`.
78   */
79  languageCode: string;
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 `'USD'`, `'EUR'`, `'PLN'`.
88   */
89  currencyCode: string | null;
90  /**
91   * Currency symbol for the locale.
92   * Is `null` on Web, use a table lookup based on region (if available) instead.
93   * @example `'$'`, `'€'`, `'zł'`.
94   */
95  currencySymbol: string | null;
96  /**
97   * Decimal separator used for formatting numbers with fractional parts.
98   * @example `'.'`, `','`.
99   */
100  decimalSeparator: string | null;
101  /**
102   * Digit grouping separator used for formatting large numbers.
103   * @example `'.'`, `','`.
104   */
105  digitGroupingSeparator: string | null;
106  /**
107   * 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.
108   */
109  textDirection: 'ltr' | 'rtl' | null;
110  /**
111   * The measurement system used in the locale.
112   * Is `null` on Web, as user chosen measurement system is not exposed on the web and using locale to determine measurement systems is unreliable.
113   * Ask for user preferences if possible.
114   */
115  measurementSystem: `metric` | `us` | `uk` | null;
116};
117
118/**
119 * An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.
120 */
121export enum Weekday {
122  SUNDAY = 1,
123  MONDAY = 2,
124  TUESDAY = 3,
125  WEDNESDAY = 4,
126  THURSDAY = 5,
127  FRIDAY = 6,
128  SATURDAY = 7,
129}
130
131/**
132 * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
133 * Gregorian calendar is aliased and can be referred to as both `CalendarIdentifier.GREGORIAN` and `CalendarIdentifier.GREGORY`.
134 */
135export enum CalendarIdentifier {
136  /** Thai Buddhist calendar */
137  BUDDHIST = 'buddhist',
138  /** Traditional Chinese calendar */
139  CHINESE = 'chinese',
140  /** Coptic calendar */
141  COPTIC = 'coptic',
142  /** Traditional Korean calendar */
143  DANGI = 'dangi',
144  /** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */
145  ETHIOAA = 'ethioaa',
146  /** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */
147  ETHIOPIC = 'ethiopic',
148  /** Gregorian calendar */
149  GREGORY = 'gregory',
150  /** Gregorian calendar (alias) */
151  GREGORIAN = 'gregory',
152  /** Traditional Hebrew calendar */
153  HEBREW = 'hebrew',
154  /** Indian calendar */
155  INDIAN = 'indian',
156  /** Islamic calendar */
157  ISLAMIC = 'islamic',
158  /** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */
159  ISLAMIC_CIVIL = 'islamic-civil',
160  /** Islamic calendar, Saudi Arabia sighting */
161  ISLAMIC_RGSA = 'islamic-rgsa',
162  /**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */
163  ISLAMIC_TBLA = 'islamic-tbla',
164  /** Islamic calendar, Umm al-Qura */
165  ISLAMIC_UMALQURA = 'islamic-umalqura',
166  /** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */
167  ISO8601 = 'iso8601',
168  /** Japanese imperial calendar */
169  JAPANESE = 'japanese',
170  /** Persian calendar */
171  PERSIAN = 'persian',
172  /** Civil (algorithmic) Arabic calendar */
173  ROC = 'roc',
174}
175
176export type Calendar = {
177  /**
178   * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).
179   *
180   * On Android is limited to one of device's [available calendar types](https://developer.android.com/reference/java/util/Calendar#getAvailableCalendarTypes()).
181   *
182   * 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.
183   */
184  calendar: CalendarIdentifier | null;
185  /**
186   * True when current device settings use 24 hour time format.
187   * 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.
188   */
189  uses24hourClock: boolean | null;
190  /**
191   * The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.
192   * 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.
193   * @example `1`, `7`.
194   */
195  firstWeekday: Weekday | null;
196  /**
197   * Time zone for the calendar. Can be `null` on Web.
198   * @example `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.
199   */
200  timeZone: string | null;
201};
202