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 * The temperature unit used in the locale. 119 * Returns `null` if the region code is unknown. 120 */ 121 temperatureUnit: 'celsius' | 'fahrenheit' | null; 122}; 123 124/** 125 * An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property. 126 */ 127export enum Weekday { 128 SUNDAY = 1, 129 MONDAY = 2, 130 TUESDAY = 3, 131 WEDNESDAY = 4, 132 THURSDAY = 5, 133 FRIDAY = 6, 134 SATURDAY = 7, 135} 136 137/** 138 * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar). 139 * Gregorian calendar is aliased and can be referred to as both `CalendarIdentifier.GREGORIAN` and `CalendarIdentifier.GREGORY`. 140 */ 141export enum CalendarIdentifier { 142 /** Thai Buddhist calendar */ 143 BUDDHIST = 'buddhist', 144 /** Traditional Chinese calendar */ 145 CHINESE = 'chinese', 146 /** Coptic calendar */ 147 COPTIC = 'coptic', 148 /** Traditional Korean calendar */ 149 DANGI = 'dangi', 150 /** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */ 151 ETHIOAA = 'ethioaa', 152 /** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */ 153 ETHIOPIC = 'ethiopic', 154 /** Gregorian calendar */ 155 GREGORY = 'gregory', 156 /** Gregorian calendar (alias) */ 157 GREGORIAN = 'gregory', 158 /** Traditional Hebrew calendar */ 159 HEBREW = 'hebrew', 160 /** Indian calendar */ 161 INDIAN = 'indian', 162 /** Islamic calendar */ 163 ISLAMIC = 'islamic', 164 /** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */ 165 ISLAMIC_CIVIL = 'islamic-civil', 166 /** Islamic calendar, Saudi Arabia sighting */ 167 ISLAMIC_RGSA = 'islamic-rgsa', 168 /**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */ 169 ISLAMIC_TBLA = 'islamic-tbla', 170 /** Islamic calendar, Umm al-Qura */ 171 ISLAMIC_UMALQURA = 'islamic-umalqura', 172 /** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */ 173 ISO8601 = 'iso8601', 174 /** Japanese imperial calendar */ 175 JAPANESE = 'japanese', 176 /** Persian calendar */ 177 PERSIAN = 'persian', 178 /** Civil (algorithmic) Arabic calendar */ 179 ROC = 'roc', 180} 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 `1`, `7`. 200 */ 201 firstWeekday: Weekday | null; 202 /** 203 * Time zone for the calendar. Can be `null` on Web. 204 * @example `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`. 205 */ 206 timeZone: string | null; 207}; 208