@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
package/.eslintrc.js ADDED
@@ -0,0 +1,2 @@
1
+ // @generated by expo-module-scripts
2
+ module.exports = require('expo-module-scripts/eslintrc.base.js');
package/CHANGELOG.md ADDED
@@ -0,0 +1,198 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ ### 🎉 New features
8
+
9
+ ### 🐛 Bug fixes
10
+
11
+ ### 💡 Others
12
+
13
+ ## 14.6.0 — 2023-10-17
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [iOS] fix tvOS compilation. ([#24845](https://github.com/expo/expo/pull/24845) by [@douglowder](https://github.com/douglowder))
22
+
23
+ ## 14.5.0 — 2023-09-04
24
+
25
+ ### 🎉 New features
26
+
27
+ - Added support for React Native 0.73. ([#24018](https://github.com/expo/expo/pull/24018) by [@kudo](https://github.com/kudo))
28
+ - Added a `temperatureUnit` field, which contains the default temperature unit for the locale. ([#24059](https://github.com/expo/expo/pull/24059) by [@behenate](https://github.com/behenate))
29
+
30
+ ### 💡 Others
31
+
32
+ - Change documentation to refer to a correct replacement method in a deprecated field. ([#23811](https://github.com/expo/expo/pull/23811) by [@aleqsio](https://github.com/aleqsio))
33
+
34
+ ## 14.4.0 — 2023-08-02
35
+
36
+ _This version does not introduce any user-facing changes._
37
+
38
+ ## 14.3.0 — 2023-06-21
39
+
40
+ ### 🎉 New features
41
+
42
+ - Changing locale on Android no longer reloads the app if the `expo-localization` config plugin is added to app.json. ([#22763](https://github.com/expo/expo/pull/22763) by [@aleqsio](https://github.com/aleqsio))
43
+ - Added hooks to get current locale and calendar. ([#22763](https://github.com/expo/expo/pull/22763) by [@aleqsio](https://github.com/aleqsio))
44
+ - Measurement system now returns `uk` and `us` values on iOS 16 and higher. ([#22763](https://github.com/expo/expo/pull/22763) by [@aleqsio](https://github.com/aleqsio))
45
+
46
+ ### 🐛 Bug fixes
47
+
48
+ - User settings for delimiters and other locale preferences now override default locale settings for each locale in the list. ([#22763](https://github.com/expo/expo/pull/22763) by [@aleqsio](https://github.com/aleqsio))
49
+ - Fixed Android build warnings for Gradle version 8. ([#22537](https://github.com/expo/expo/pull/22537), [#22609](https://github.com/expo/expo/pull/22609) by [@kudo](https://github.com/kudo))
50
+
51
+ ## 14.2.0 — 2023-05-08
52
+
53
+ ### 🐛 Bug fixes
54
+
55
+ - Fixed invalid timezone returned for `getCalendars` on Web. ([#22003](https://github.com/expo/expo/pull/22003) by [@aleqsio](https://github.com/aleqsio))
56
+ - Fixed errors thrown on Play Console pre-launch report. ([#22003](https://github.com/expo/expo/pull/22003) by [@aleqsio](https://github.com/aleqsio))
57
+
58
+ ## 14.1.1 — 2023-02-09
59
+
60
+ _This version does not introduce any user-facing changes._
61
+
62
+ ## 14.1.0 — 2023-02-03
63
+
64
+ ### 💡 Others
65
+
66
+ - On Android bump `compileSdkVersion` and `targetSdkVersion` to `33`. ([#20721](https://github.com/expo/expo/pull/20721) by [@lukmccall](https://github.com/lukmccall))
67
+
68
+ ## 14.0.0 — 2022-10-25
69
+
70
+ ### 🛠 Breaking changes
71
+
72
+ - Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
73
+
74
+ ### 🎉 New features
75
+
76
+ - Added two new synchronous functions: `getLocales` and `getCalendars`. ([#19019](https://github.com/expo/expo/pull/19019) by [@aleqsio](https://github.com/aleqsio))
77
+ - Added a `supportsRTL` manifest flag for enabling RTL on suitable locales. ([#19634](https://github.com/expo/expo/pull/19634) by [@aleqsio](https://github.com/aleqsio))
78
+
79
+ ### 🐛 Bug fixes
80
+
81
+ - Fixed build error for setting `compileSdkVersion` to 33. ([#19518](https://github.com/expo/expo/pull/19518) by [@kudo](https://github.com/kudo))
82
+
83
+ ### ⚠️ Notices
84
+
85
+ - Deprecated existing constants API while keeping backwards compatibility. ([#19019](https://github.com/expo/expo/pull/19019) by [@aleqsio](https://github.com/aleqsio))
86
+
87
+ ## 13.1.0 — 2022-07-07
88
+
89
+ ### 🎉 New features
90
+
91
+ - Native module on Android is now written in Kotlin using the new API. ([#17775](https://github.com/expo/expo/pull/17775) by [@barthap](https://github.com/barthap))
92
+
93
+ ### 💡 Others
94
+
95
+ - Migrated Expo modules definitions to the new naming convention. ([#17193](https://github.com/expo/expo/pull/17193) by [@tsapeta](https://github.com/tsapeta))
96
+
97
+ ## 13.0.0 — 2022-04-18
98
+
99
+ ### 🛠 Breaking changes
100
+
101
+ - Guess the device language on iOS rather than using the app-specific language. ([#15807](https://github.com/expo/expo/pull/15807) by [@EvanBacon](https://github.com/EvanBacon))
102
+
103
+ ### 🎉 New features
104
+
105
+ - Use JSI host object instead of the bridge module for communication between JavaScript and native code. ([#16972](https://github.com/expo/expo/pull/16972) by [@tsapeta](https://github.com/tsapeta))
106
+
107
+ ### 🐛 Bug fixes
108
+
109
+ - Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.NullPointerException ([#16316](https://github.com/expo/expo/pull/16316) by [@nomi9995](https://github.com/nomi9995))
110
+
111
+ ### ⚠️ Notices
112
+
113
+ - On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
114
+
115
+ ## 12.0.1 - 2022-02-01
116
+
117
+ ### 🐛 Bug fixes
118
+
119
+ - Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
120
+
121
+ ## 12.0.0 — 2021-12-03
122
+
123
+ ### 🎉 New features
124
+
125
+ - Native module on iOS is now written in Swift using the new API. ([#15266](https://github.com/expo/expo/pull/15266) by [@tsapeta](https://github.com/tsapeta))
126
+
127
+ ### 💡 Others
128
+
129
+ - Rewrite module to Kotlin. ([#14588](https://github.com/expo/expo/pull/14588) by [@mstach60161](https://github.com/mstach60161))
130
+
131
+ ## 11.0.0 — 2021-09-28
132
+
133
+ ### 🛠 Breaking changes
134
+
135
+ - Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
136
+
137
+ ### 🐛 Bug fixes
138
+
139
+ - Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
140
+
141
+ ## 10.2.0 — 2021-06-16
142
+
143
+ ### 🐛 Bug fixes
144
+
145
+ - Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman))
146
+
147
+ ### 💡 Others
148
+
149
+ - Build Android code using Java 8 to fix Android instrumented test build error. ([#12939](https://github.com/expo/expo/pull/12939) by [@kudo](https://github.com/kudo))
150
+
151
+ ## 10.1.0 — 2021-03-10
152
+
153
+ ### 🎉 New features
154
+
155
+ - Updated Android build configuration to target Android 11 (added support for Android SDK 30). ([#11647](https://github.com/expo/expo/pull/11647) by [@bbarthec](https://github.com/bbarthec))
156
+ - Add `currency`, `isMetric`, `decimalSeparator`, `digitGroupingSeparator` properties. ([#11663](https://github.com/expo/expo/pull/11663) by [@IjzerenHein](https://github.com/IjzerenHein))
157
+ - Add support for `region` property for Android. ([#11663](https://github.com/expo/expo/pull/11663) by [@IjzerenHein](https://github.com/IjzerenHein))
158
+
159
+ ### 🐛 Bug fixes
160
+
161
+ - Fix invalid `region` property on Web when locale contains script or variant fields. ([#11663](https://github.com/expo/expo/pull/11663) by [@IjzerenHein](https://github.com/IjzerenHein))
162
+ - Remove peerDependencies and unimodulePeerDependencies from Expo modules. ([#11980](https://github.com/expo/expo/pull/11980) by [@brentvatne](https://github.com/brentvatne))
163
+
164
+ ## 10.0.0 — 2021-01-15
165
+
166
+ ### 🛠 Breaking changes
167
+
168
+ - Dropped support for iOS 10.0 ([#11344](https://github.com/expo/expo/pull/11344) by [@tsapeta](https://github.com/tsapeta))
169
+
170
+ ## 9.1.0 — 2020-11-17
171
+
172
+ _This version does not introduce any user-facing changes._
173
+
174
+ ## 9.0.0 — 2020-08-18
175
+
176
+ ### 🛠 Breaking changes
177
+
178
+ - `Localization.region` changed from `undefined | string` to `null | string` on web to match iOS. ([#8824](https://github.com/expo/expo/pull/8824) by [@EvanBacon](https://github.com/EvanBacon))
179
+
180
+ ### 🎉 New features
181
+
182
+ - Added doc blocks for everything. ([#8824](https://github.com/expo/expo/pull/8824) by [@EvanBacon](https://github.com/EvanBacon))
183
+ - Added support for SSR environments. ([#8824](https://github.com/expo/expo/pull/8824) by [@EvanBacon](https://github.com/EvanBacon))
184
+ - `Localization.isRTL` defaults to `false` in node environments. ([#8824](https://github.com/expo/expo/pull/8824) by [@EvanBacon](https://github.com/EvanBacon))
185
+
186
+ ### 🐛 Bug fixes
187
+
188
+ - `Localization.region` now returns `null` when a partial `locale` is defined by the browser on web. ([#8824](https://github.com/expo/expo/pull/8824) by [@EvanBacon](https://github.com/EvanBacon))
189
+
190
+ ## 8.2.1 — 2020-05-29
191
+
192
+ _This version does not introduce any user-facing changes._
193
+
194
+ ## 8.2.0 — 2020-05-27
195
+
196
+ ### 🐛 Bug fixes
197
+
198
+ - Fixed `Localization.locale` throwing an exception on the iOS simulator. ([#8193](https://github.com/expo/expo/pull/8193) by [@lukmccall](https://github.com/lukmccall))
package/CMakeLists.txt ADDED
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright 2023 Amazon.com, Inc. or its affiliates. All rights reserved.
3
+ #
4
+ # AMAZON PROPRIETARY/CONFIDENTIAL
5
+ #
6
+ # You may not use this file except in compliance with the terms and conditions
7
+ # set forth in the accompanying LICENSE.TXT file.
8
+ #
9
+ # THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
10
+ # DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
11
+ # IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
12
+ # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
13
+ #
14
+ set(PACKAGE_NAME "expo-localization")
15
+ set(AUTO_LINK_PACKAGE_NAME "${PACKAGE_NAME}-${KEPLER_REACT_NATIVE_MAJOR_VERSION}")
16
+ set(SOURCES_KEPLER kepler/ExpoLocalization.cpp)
17
+
18
+ find_package(ICU COMPONENTS i18n)
19
+
20
+ add_library(${PACKAGE_NAME} STATIC ${SOURCES_KEPLER})
21
+
22
+ target_link_libraries(
23
+ ${PACKAGE_NAME}
24
+ PUBLIC
25
+ keplerui::keplerscript-${KEPLER_REACT_NATIVE_MAJOR_VERSION}
26
+ ICU::i18n
27
+ )
28
+
29
+ add_library(${AUTO_LINK_PACKAGE_NAME} SHARED kepler/KeplerInit.cpp)
30
+
31
+ set_target_properties(${AUTO_LINK_PACKAGE_NAME} PROPERTIES SOVERSION ${KEPLER_REACT_NATIVE_MAJOR_VERSION}.${KEPLER_REACT_NATIVE_MINOR_VERSION})
32
+
33
+ target_link_libraries(
34
+ ${AUTO_LINK_PACKAGE_NAME}
35
+ PRIVATE
36
+ ${PACKAGE_NAME}
37
+ )
38
+
39
+ # Helps in checking undefined references
40
+ add_executable(${AUTO_LINK_PACKAGE_NAME}_exe kepler/KeplerInit.cpp)
41
+ target_link_libraries(${AUTO_LINK_PACKAGE_NAME}_exe
42
+ PRIVATE
43
+ ${AUTO_LINK_PACKAGE_NAME}
44
+ keplerui::keplerscript-${KEPLER_REACT_NATIVE_MAJOR_VERSION}
45
+ ICU::i18n
46
+ )
47
+
48
+ install(TARGETS ${AUTO_LINK_PACKAGE_NAME}
49
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
50
+ )
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
2
+
3
+ These materials are licensed as "Program Materials" under the Program Materials License Agreement (the "Agreement"). The Agreement is available at https://developer.amazon.com/support/legal/pml. See the Agreement for the specific terms and conditions of the Agreement. Capitalized terms not defined in this file have the meanings given to them in the Agreement.
4
+
5
+ If you do not agree to the above terms and conditions, you may not use any file in this package.
6
+
7
+ YOUR USE OF THE PROGRAM MATERIALS IN OR ASSOCIATED WITH THIS PACKAGE IS AT YOUR SOLE RISK. IN NO EVENT WILL AMAZON BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL, INCIDENTAL, OR PUNITIVE DAMAGES (INCLUDING FOR ANY LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, OR COMPUTER FAILURE OR MALFUNCTION) ARISING FROM OR RELATING TO SUCH PROGRAM MATERIALS, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, EVEN IF AMAZON HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS AND DISCLAIMERS APPLY EXCEPT TO THE EXTENT PROHIBITED BY APPLICABLE LAW.
@@ -0,0 +1,109 @@
1
+ # @amazon-devices/expo-localization
2
+
3
+ ## Getting Started
4
+
5
+ `@amazon-devices/expo-localization` provides an interface for native user localization information.
6
+
7
+ It provdes `getCalendars()` and `getLocales()` method and their corresponding hooks, which return specific information about user's locale settings, e.g. `languageCode`, `uses24HourClock`, `currencyCode` and `textDirection`. It itself doesn't provide any methods for formatting text or values. Hooks will trigger a re-render when the app locale changes.
8
+
9
+ This is a system-deployed library and is available to KeplerScript apps without a separate installation process. It is deployed as an autolinking library which your app links to at runtime. Compatibility is guaranteed only between the library and the version of KeplerScript for which it is built.
10
+
11
+ ### Installation
12
+
13
+ 1. Add the JavaScript library dependency in the `package.json` file:
14
+ ```json
15
+ "dependencies": {
16
+ ...
17
+ "@amazon-devices/expo-localization": "^2.0.0",
18
+ "@amazon-devices/keplerscript-turbomodule-api": "^1.0.0",
19
+ ...
20
+ }
21
+ ```
22
+
23
+ 2. Reinstall dependencies using `npm install` command.
24
+
25
+ ## Usage Examples
26
+
27
+ Example of retrieving user's language code:
28
+
29
+ ```js
30
+ import React from 'react';
31
+ import {StyleSheet, Text, View} from 'react-native';
32
+ import {useLocales, useCalendars} from '@amazon-devices/expo-localization';
33
+
34
+ export const App = () => {
35
+ const locales = useLocales();
36
+ const calendars = useCalendars();
37
+
38
+ return (
39
+ <View style={styles.container}>
40
+ <Text style={styles.text}>useLocales():</Text>
41
+ <Text style={styles.text}>{JSON.stringify(locales, null, 2)}</Text>
42
+ <Text style={styles.text}>useCalendars():</Text>
43
+ <Text style={styles.text}>{JSON.stringify(calendars, null, 2)}</Text>
44
+ </View>
45
+ );
46
+ };
47
+
48
+ const styles = StyleSheet.create({
49
+ container: {
50
+ flex: 1,
51
+ flexDirection: 'row',
52
+ backgroundColor: 'white',
53
+ },
54
+ text: {
55
+ color: 'black',
56
+ fontSize: 32,
57
+ },
58
+ });
59
+
60
+
61
+ ```
62
+
63
+ ## API Reference
64
+
65
+ Check out the dedicated documentation page for info about this library, API reference and more: [Official Expo documentation for expo-localization](https://github.com/expo/expo/blob/sdk-49/docs/pages/versions/v49.0.0/sdk/localization.mdx).
66
+
67
+ ### Constants
68
+
69
+ | Constant | Description | Platform support |
70
+ | -------- | ----------- | ---------------- |
71
+ | currency | WARNING: Deprecated. Use Localization.getLocales() instead. Three-character ISO 4217 currency code. Returns null on web | Android, iOS |
72
+ | decimalSeparator | WARNING: Deprecated. Use Localization.getLocales() instead. Decimal separator used for formatting numbers | Android, iOS |
73
+ | digitGroupingSeparator | WARNING: Deprecated. Use Localization.getLocales() instead. Digit grouping separator used when formatting numbers larger than 1000 | Android, iOS |
74
+ | isMetric | WARNING: Deprecated. Use Localization.getLocales() instead. Boolean value that indicates whether the system uses the metric system. On Android and web, this is inferred from the current region | Android, iOS |
75
+ | isRTL | WARNING: Deprecated. Use Localization.getLocales() instead. Returns if the system's language is written from Right-to-Left. This can be used to build features like bidirectional icons. Returns `false` in Server Side Rendering (SSR) environments | Android, iOS |
76
+ | isoCurrencyCodes | WARNING: Deprecated. Use Localization.getLocales() instead. A list of all the supported language ISO codes | Android, iOS |
77
+ | locale | Consider using Localization.getLocales() for a list of user preferred locales instead. An IETF BCP 47 language tag, consisting of a two-character language code and optional script, region and variant codes | All |
78
+ | locales | WARNING: Deprecated. Use Localization.getLocales() instead. List of all the native languages provided by the user settings. These are returned in the order the user defines in their device settings | Android, iOS |
79
+ | region | WARNING: Deprecated. Use Localization.getLocales() instead. The region code for your device that comes from the Region setting under Language & Region on iOS. This value is always available on iOS, but might return null on Android or web | Android, iOS |
80
+ | timezone | WARNING: Deprecated. Use Localization.getLocales() instead. The current time zone in display format. On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a better estimation you could use the moment-timezone package but it will add significant bloat to your website's bundle size | Android, iOS |
81
+
82
+ ### Hooks
83
+
84
+ | Hook | Description | Platform support |
85
+ | -------- | ----------- | ---------------- |
86
+ | useCalendars | A hook providing a list of user's preferred calendars, returned as an array of objects of type Calendar. Guaranteed to contain at least 1 element. For now always returns a single element, but it's likely to return a user preference list on some platforms in the future. If the OS settings change, the hook will rerender with a new list of calendars | All |
87
+ | useLocales | A hook providing a list of user's locales, returned as an array of objects of type Locale. Guaranteed to contain at least 1 element. These are returned in the order the user defines in their device settings. On the web currency and measurements systems are not provided, instead returned as null. If needed, you can infer them from the current region using a lookup table. If the OS settings change, the hook will rerender with a new list of locales | All |
88
+
89
+ ### Methods
90
+
91
+ | Method | Description | Platform support |
92
+ | ------ | ----------- | ---------------- |
93
+ | getCalendars | List of user's preferred calendars, returned as an array of objects of type Calendar. Guaranteed to contain at least 1 element. For now always returns a single element, but it's likely to return a user preference list on some platforms in the future | All |
94
+ | getLocales | List of user's locales, returned as an array of objects of type Locale. Guaranteed to contain at least 1 element. These are returned in the order the user defines in their device settings. On the web currency and measurements systems are not provided, instead returned as null. If needed, you can infer them from the current region using a lookup table | All |
95
+ | getLocalizationAsync | WARNING: Deprecated. Use Localization.getLocales() or Localization.getCalendars() instead | Android, iOS |
96
+
97
+ ## Known Issues
98
+
99
+ * The `region` field on `Localization` type is always null on Kepler.
100
+
101
+ * Functions `useLocales()`, `useCalendars()`, `getCalendars()` and `getLocales()` will always return array with one item in it, while other platforms could return empty array or multiple valid locales/calendars.
102
+
103
+ * The deprecated constants and method: `getLocalizationAsync()` aren't supported on Kepler
104
+
105
+ ## Supported Versions
106
+
107
+ | Package version | Based on | @amazon-devices/react-native-kepler version |
108
+ | ---------------- | -------- | --------------------------------- |
109
+ | 2.0.x | expo-localization v14.6.0 | 2.0.x |
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ <p>
2
+ <a href="https://docs.expo.dev/versions/latest/sdk/localization/">
3
+ <img
4
+ src="../../.github/resources/expo-localization.svg"
5
+ alt="expo-localization"
6
+ height="64" />
7
+ </a>
8
+ </p>
9
+
10
+ Provides an interface for native user localization information.
11
+
12
+ # API documentation
13
+
14
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/localization.mdx)
15
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/localization/)
16
+
17
+ # Installation in managed Expo projects
18
+
19
+ For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/localization/).
20
+
21
+ # Installation in bare React Native projects
22
+
23
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
24
+
25
+ ### Add the package to your npm dependencies
26
+
27
+ ```
28
+ npx expo install expo-localization
29
+ ```
30
+
31
+ ### Configure for iOS
32
+
33
+ Run `npx pod-install` after installing the npm package.
34
+
35
+ ### Configure for Android
36
+
37
+ No additional set up necessary.
38
+
39
+ # Contributing
40
+
41
+ Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
@@ -0,0 +1,24 @@
1
+ License from package.json:
2
+ ==============================
3
+
4
+ The MIT License (MIT)
5
+
6
+ Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
@@ -0,0 +1,109 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+ apply plugin: 'maven-publish'
4
+
5
+ group = 'host.exp.exponent'
6
+ version = '14.6.0'
7
+
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ // Remove this check, but keep the contents after SDK49 support is dropped
13
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
+ useExpoPublishing()
15
+ useCoreDependencies()
16
+ }
17
+ }
18
+
19
+ buildscript {
20
+ // Simple helper that allows the root project to override versions declared by this library.
21
+ ext.safeExtGet = { prop, fallback ->
22
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
+ }
24
+
25
+ // Ensures backward compatibility
26
+ ext.getKotlinVersion = {
27
+ if (ext.has("kotlinVersion")) {
28
+ ext.kotlinVersion()
29
+ } else {
30
+ ext.safeExtGet("kotlinVersion", "1.8.10")
31
+ }
32
+ }
33
+
34
+ repositories {
35
+ mavenCentral()
36
+ }
37
+
38
+ dependencies {
39
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
+ }
41
+ }
42
+
43
+ // Remove this if and it's contents, when support for SDK49 is dropped
44
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ }
51
+ }
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ android {
62
+ // Remove this if and it's contents, when support for SDK49 is dropped
63
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
+ compileSdkVersion safeExtGet("compileSdkVersion", 33)
65
+
66
+ defaultConfig {
67
+ minSdkVersion safeExtGet("minSdkVersion", 23)
68
+ targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
+ }
70
+
71
+ publishing {
72
+ singleVariant("release") {
73
+ withSourcesJar()
74
+ }
75
+ }
76
+
77
+ lintOptions {
78
+ abortOnError false
79
+ }
80
+ }
81
+
82
+ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
+ if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
+ compileOptions {
85
+ sourceCompatibility JavaVersion.VERSION_11
86
+ targetCompatibility JavaVersion.VERSION_11
87
+ }
88
+
89
+ kotlinOptions {
90
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
91
+ }
92
+ }
93
+
94
+ namespace "expo.modules.localization"
95
+ defaultConfig {
96
+ versionCode 22
97
+ versionName "14.6.0"
98
+ }
99
+ }
100
+
101
+ dependencies {
102
+ // Remove this if and it's contents, when support for SDK49 is dropped
103
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
+ implementation project(':expo-modules-core')
105
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
+ }
107
+
108
+ implementation "androidx.core:core-ktx:1.6.0"
109
+ }
@@ -0,0 +1,3 @@
1
+ <manifest>
2
+
3
+ </manifest>