@amazon-devices/expo-localization 2.0.1758683737

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +198 -0
  3. package/CMakeLists.txt +50 -0
  4. package/LICENSE +7 -0
  5. package/README.kepler.md +109 -0
  6. package/README.md +41 -0
  7. package/THIRD_PARTY_NOTICES.txt +24 -0
  8. package/android/build.gradle +109 -0
  9. package/android/src/main/AndroidManifest.xml +3 -0
  10. package/android/src/main/java/expo/modules/localization/LocalizationModule.kt +207 -0
  11. package/android/src/main/java/expo/modules/localization/LocalizationPackage.kt +35 -0
  12. package/android/src/main/java/expo/modules/localization/LocalizationUtils.kt +49 -0
  13. package/android/src/main/res/values/strings.xml +4 -0
  14. package/app.plugin.js +1 -0
  15. package/build/ExpoLocalization.d.ts +22 -0
  16. package/build/ExpoLocalization.d.ts.map +1 -0
  17. package/build/ExpoLocalization.js +166 -0
  18. package/build/ExpoLocalization.js.map +1 -0
  19. package/build/ExpoLocalization.kepler.d.ts +12 -0
  20. package/build/ExpoLocalization.kepler.d.ts.map +1 -0
  21. package/build/ExpoLocalization.kepler.js +26 -0
  22. package/build/ExpoLocalization.kepler.js.map +1 -0
  23. package/build/ExpoLocalization.native.d.ts +7 -0
  24. package/build/ExpoLocalization.native.d.ts.map +1 -0
  25. package/build/ExpoLocalization.native.js +14 -0
  26. package/build/ExpoLocalization.native.js.map +1 -0
  27. package/build/Localization.d.ts +163 -0
  28. package/build/Localization.d.ts.map +1 -0
  29. package/build/Localization.js +197 -0
  30. package/build/Localization.js.map +1 -0
  31. package/build/Localization.types.d.ts +202 -0
  32. package/build/Localization.types.d.ts.map +1 -0
  33. package/build/Localization.types.js +59 -0
  34. package/build/Localization.types.js.map +1 -0
  35. package/expo-module.config.json +10 -0
  36. package/ios/ExpoLocalization.podspec +32 -0
  37. package/ios/LocalizationModule.swift +212 -0
  38. package/kepler/ExpoLocalization.cpp +128 -0
  39. package/kepler/ExpoLocalization.h +22 -0
  40. package/kepler/KeplerInit.cpp +26 -0
  41. package/kepler/test/ExpoLocalization.cpp +78 -0
  42. package/package.json +1 -0
  43. package/plugin/build/withExpoLocalization.d.ts +7 -0
  44. package/plugin/build/withExpoLocalization.js +46 -0
  45. package/plugin/src/withExpoLocalization.ts +62 -0
  46. package/plugin/tsconfig.json +9 -0
  47. package/plugin/tsconfig.tsbuildinfo +1 -0
  48. package/react-native.config.js +21 -0
  49. package/src/ExpoLocalization.kepler.ts +40 -0
  50. package/src/ExpoLocalization.native.ts +18 -0
  51. package/src/ExpoLocalization.ts +203 -0
  52. package/src/Localization.ts +217 -0
  53. package/src/Localization.types.ts +207 -0
  54. package/tsconfig.json +9 -0
@@ -0,0 +1,207 @@
1
+ // @needsAudit
2
+ export 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
+
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 `'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
+ */
127
+ export 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
+ */
141
+ export 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
+
182
+ export 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
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }