1import ExpoLocalization from './ExpoLocalization';
2import { Localization } from './Localization.types';
3export * from './Localization.types';
4
5// @needsAudit
6/**
7 * @deprecated Use Localization.getLocales() instead.
8 * Three-character ISO 4217 currency code. Returns `null` on web.
9 *
10 * @example `'USD'`, `'EUR'`, `'CNY'`, `null`
11 */
12export const currency = ExpoLocalization.currency;
13
14// @needsAudit
15/**
16 * @deprecated Use Localization.getLocales() instead.
17 * Decimal separator used for formatting numbers.
18 *
19 * @example `','`, `'.'`
20 */
21export const decimalSeparator = ExpoLocalization.decimalSeparator;
22
23// @needsAudit
24/**
25 * @deprecated Use Localization.getLocales() instead.
26 * Digit grouping separator used when formatting numbers larger than 1000.
27 *
28 * @example `'.'`, `''`, `','`
29 */
30export const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;
31
32// @needsAudit
33/**
34 * @deprecated Use Localization.getLocales() instead.
35 * A list of all the supported language ISO codes.
36 */
37export const isoCurrencyCodes = ExpoLocalization.isoCurrencyCodes;
38
39// @needsAudit
40/**
41 * @deprecated Use Localization.getLocales() instead.
42 * Boolean value that indicates whether the system uses the metric system.
43 * On Android and web, this is inferred from the current region.
44 */
45export const isMetric = ExpoLocalization.isMetric;
46
47// @needsAudit
48/**
49 * @deprecated Use Localization.getLocales() instead.
50 * Returns if the system's language is written from Right-to-Left.
51 * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).
52 *
53 * Returns `false` in Server Side Rendering (SSR) environments.
54 */
55export const isRTL = ExpoLocalization.isRTL;
56
57// @needsAudit
58/**
59 * Consider using Localization.getLocales() for a list of user preferred locales instead.
60 * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
61 * consisting of a two-character language code and optional script, region and variant codes.
62 *
63 * @example `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
64 */
65export const locale = ExpoLocalization.locale;
66
67// @needsAudit
68/**
69 * @deprecated Use Localization.getLocales() instead.
70 * List of all the native languages provided by the user settings.
71 * These are returned in the order the user defines in their device settings.
72 *
73 * @example `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
74 */
75export const locales = ExpoLocalization.locales;
76
77// @needsAudit
78/**
79 * @deprecated Use Localization.getLocales() instead.
80 * The current time zone in display format.
81 * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a
82 * better estimation you could use the moment-timezone package but it will add significant bloat to
83 * your website's bundle size.
84 *
85 * @example `'America/Los_Angeles'`
86 */
87export const timezone = ExpoLocalization.timezone;
88
89// @needsAudit
90/**
91 * @deprecated Use Localization.getLocales() instead.
92 * The region code for your device that comes from the Region setting under Language & Region on iOS.
93 * This value is always available on iOS, but might return `null` on Android or web.
94 *
95 * @example `'US'`, `'NZ'`, `null`
96 */
97export const region = ExpoLocalization.region;
98
99/**
100 * List of user's locales, returned as an array of objects of type `Locale`.
101 * Guaranteed to contain at least 1 element.
102 * These are returned in the order the user defines in their device settings.
103 * On the web currency and measurements systems are not provided, instead returned as null.
104 * If needed, you can infer them from the current region using a lookup table.
105 * @example `[{
106    "languageTag": "pl-PL",
107    "languageCode": "pl",
108    "textDirection": "ltr",
109    "digitGroupingSeparator": " ",
110    "decimalSeparator": ",",
111    "measurementSystem": "metric",
112    "currencyCode": "PLN",
113    "currencySymbol": "zł",
114    "regionCode": "PL"
115  }]`
116 */
117export const getLocales = ExpoLocalization.getLocales;
118
119/**
120 * List of user's preferred calendars, returned as an array of objects of type `Calendar`.
121 * Guaranteed to contain at least 1 element.
122 * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
123 * @example `[
124    {
125      "calendar": "gregory",
126      "timeZone": "Europe/Warsaw",
127      "uses24hourClock": true,
128      "firstWeekday": 1
129    }
130  ]`
131 */
132export const getCalendars = ExpoLocalization.getCalendars;
133
134// @needsAudit
135/**
136 * Get the latest native values from the device. Locale can be changed on some Android devices
137 * without resetting the app.
138 * > On iOS, changing the locale will cause the device to reset meaning the constants will always be
139 * correct.
140 *
141 * @example
142 * ```ts
143 * // When the app returns from the background on Android...
144 *
145 * const { locale } = await Localization.getLocalizationAsync();
146 * ```
147 * @deprecated
148 * Use Localization.getLocales() or Localization.getCalendars() instead.
149 */
150export async function getLocalizationAsync(): Promise<Localization> {
151  return await ExpoLocalization.getLocalizationAsync();
152}
153