expo-localization 14.2.0 → 14.4.0

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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,23 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 14.4.0 — 2023-08-02
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 14.3.0 — 2023-06-21
18
+
19
+ ### 🎉 New features
20
+
21
+ - 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))
22
+ - Added hooks to get current locale and calendar. ([#22763](https://github.com/expo/expo/pull/22763) by [@aleqsio](https://github.com/aleqsio))
23
+ - 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))
24
+
25
+ ### 🐛 Bug fixes
26
+
27
+ - 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))
28
+ - 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))
29
+
13
30
  ## 14.2.0 — 2023-05-08
14
31
 
15
32
  ### 🐛 Bug fixes
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '14.2.0'
6
+ version = '14.4.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -35,19 +35,11 @@ buildscript {
35
35
  }
36
36
  }
37
37
 
38
- // Creating sources with comments
39
- task androidSourcesJar(type: Jar) {
40
- classifier = 'sources'
41
- from android.sourceSets.main.java.srcDirs
42
- }
43
-
44
38
  afterEvaluate {
45
39
  publishing {
46
40
  publications {
47
41
  release(MavenPublication) {
48
42
  from components.release
49
- // Add additional sourcesJar to artifacts
50
- artifact(androidSourcesJar)
51
43
  }
52
44
  }
53
45
  repositories {
@@ -70,15 +62,21 @@ android {
70
62
  jvmTarget = JavaVersion.VERSION_11.majorVersion
71
63
  }
72
64
 
65
+ namespace "expo.modules.localization"
73
66
  defaultConfig {
74
67
  minSdkVersion safeExtGet("minSdkVersion", 21)
75
68
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
76
69
  versionCode 22
77
- versionName "14.2.0"
70
+ versionName "14.4.0"
78
71
  }
79
72
  lintOptions {
80
73
  abortOnError false
81
74
  }
75
+ publishing {
76
+ singleVariant("release") {
77
+ withSourcesJar()
78
+ }
79
+ }
82
80
  }
83
81
 
84
82
  dependencies {
@@ -1,5 +1,3 @@
1
-
2
- <manifest package="expo.modules.localization">
1
+ <manifest>
3
2
 
4
3
  </manifest>
5
-
@@ -25,7 +25,12 @@ import java.util.*
25
25
  private const val SHARED_PREFS_NAME = "com.facebook.react.modules.i18nmanager.I18nUtil"
26
26
  private const val KEY_FOR_PREFS_ALLOWRTL = "RCTI18nUtil_allowRTL"
27
27
 
28
+ private const val LOCALE_SETTINGS_CHANGED = "onLocaleSettingsChanged"
29
+ private const val CALENDAR_SETTINGS_CHANGED = "onCalendarSettingsChanged"
30
+
28
31
  class LocalizationModule : Module() {
32
+ private var observer: () -> Unit = {}
33
+
29
34
  override fun definition() = ModuleDefinition {
30
35
  Name("ExpoLocalization")
31
36
 
@@ -45,10 +50,21 @@ class LocalizationModule : Module() {
45
50
  return@Function getCalendars()
46
51
  }
47
52
 
53
+ Events(LOCALE_SETTINGS_CHANGED, CALENDAR_SETTINGS_CHANGED)
54
+
48
55
  OnCreate {
49
56
  appContext?.reactContext?.let {
50
57
  setRTLFromStringResources(it)
51
58
  }
59
+ observer = {
60
+ this@LocalizationModule.sendEvent(LOCALE_SETTINGS_CHANGED)
61
+ this@LocalizationModule.sendEvent(CALENDAR_SETTINGS_CHANGED)
62
+ }
63
+ Notifier.registerObserver(observer)
64
+ }
65
+
66
+ OnDestroy {
67
+ Notifier.deregisterObserver(observer)
52
68
  }
53
69
  }
54
70
 
@@ -0,0 +1,35 @@
1
+ package expo.modules.localization
2
+
3
+ import android.content.Context
4
+ import android.content.res.Configuration
5
+ import expo.modules.core.interfaces.ApplicationLifecycleListener
6
+ import expo.modules.core.interfaces.Package
7
+
8
+ object Notifier {
9
+ private val observers = mutableListOf<() -> Unit>()
10
+
11
+ fun registerObserver(observer: () -> Unit) {
12
+ observers.add(observer)
13
+ }
14
+
15
+ fun deregisterObserver(observer: () -> Unit) {
16
+ observers.remove(observer)
17
+ }
18
+
19
+ fun onConfigurationChanged() {
20
+ // Notify all observers
21
+ observers.forEach { it() }
22
+ }
23
+ }
24
+
25
+ // TODO: Move to new listener API once it's available
26
+ class LocalizationPackage : Package {
27
+ override fun createApplicationLifecycleListeners(context: Context?): List<out ApplicationLifecycleListener> {
28
+ return listOf(object : ApplicationLifecycleListener {
29
+ override fun onConfigurationChanged(newConfig: Configuration?) {
30
+ super.onConfigurationChanged(newConfig)
31
+ Notifier.onConfigurationChanged()
32
+ }
33
+ })
34
+ }
35
+ }
@@ -1,4 +1,8 @@
1
+ import { Subscription } from 'expo-modules-core';
1
2
  import { Localization, Calendar, Locale } from './Localization.types';
3
+ export declare function addLocaleListener(listener: (event: any) => void): Subscription;
4
+ export declare function addCalendarListener(listener: (event: any) => void): Subscription;
5
+ export declare function removeSubscription(subscription: Subscription): void;
2
6
  declare const _default: {
3
7
  readonly currency: string | null;
4
8
  readonly decimalSeparator: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLocalization.d.ts","sourceRoot":"","sources":["../src/ExpoLocalization.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAsB,MAAM,sBAAsB,CAAC;;;;;;;;;;;;kBAqF1E,MAAM,EAAE;oBA8BN,QAAQ,EAAE;4BAaI,QAAQ,KAAK,YAAY,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC;;AA/G1F,wBAyIE"}
1
+ {"version":3,"file":"ExpoLocalization.d.ts","sourceRoot":"","sources":["../src/ExpoLocalization.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAsB,MAAM,sBAAsB,CAAC;AAmB1F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,GAAG,YAAY,CAKzE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,GAAG,YAAY,CAK3E;AACD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,QAE5D;;;;;;;;;;;;kBAsEe,MAAM,EAAE;oBA8BN,QAAQ,EAAE;4BAcI,QAAQ,KAAK,YAAY,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC;;AAhH1F,wBA0IE"}
@@ -4,6 +4,22 @@ import * as rtlDetect from 'rtl-detect';
4
4
  const getNavigatorLocales = () => {
5
5
  return Platform.isDOMAvailable ? navigator.languages || [navigator.language] : [];
6
6
  };
7
+ const WEB_LANGUAGE_CHANGE_EVENT = 'languagechange';
8
+ export function addLocaleListener(listener) {
9
+ addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);
10
+ return {
11
+ remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),
12
+ };
13
+ }
14
+ export function addCalendarListener(listener) {
15
+ addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);
16
+ return {
17
+ remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),
18
+ };
19
+ }
20
+ export function removeSubscription(subscription) {
21
+ subscription.remove();
22
+ }
7
23
  export default {
8
24
  get currency() {
9
25
  // TODO: Add support
@@ -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OAAO,IAAI,KAAK,WAAW;YAC1C,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE;YACzC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAqC,CAAC;QACvD,OAAO;YACL;gBACE,QAAQ,EAAG,CAAC,MAAM,EAAE,QAAQ,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAwB,IAAI,IAAI;gBACtF,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI;gBAC5D,eAAe,EAAE,CAAC,MAAM,EAAE,SAAS,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI;gBACzF,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;aACjD;SACF,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,oBAAoB;QACxB,MAAM,EACJ,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,GACT,GAAG,IAAI,CAAC;QACT,OAAO;YACL,QAAQ;YACR,gBAAgB;YAChB,sBAAsB;YACtB,gBAAgB;YAChB,QAAQ;YACR,KAAK;YACL,MAAM;YACN,OAAO;YACP,MAAM;YACN,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["/* eslint-env browser */\nimport { Platform } from 'expo-modules-core';\nimport * as rtlDetect from 'rtl-detect';\n\nimport { Localization, Calendar, Locale, CalendarIdentifier } from './Localization.types';\n\nconst getNavigatorLocales = () => {\n return Platform.isDOMAvailable ? navigator.languages || [navigator.language] : [];\n};\n\ntype ExtendedLocale = Intl.Locale &\n // typescript definitions for navigator language don't include some modern Intl properties\n Partial<{\n textInfo: { direction: 'ltr' | 'rtl' };\n timeZones: string[];\n weekInfo: { firstDay: number };\n hourCycles: string[];\n timeZone: string;\n calendars: string[];\n }>;\n\nexport default {\n get currency(): string | null {\n // TODO: Add support\n return null;\n },\n get decimalSeparator(): string {\n return (1.1).toLocaleString().substring(1, 2);\n },\n get digitGroupingSeparator(): string {\n const value = (1000).toLocaleString();\n return value.length === 5 ? value.substring(1, 2) : '';\n },\n get isRTL(): boolean {\n return rtlDetect.isRtlLang(this.locale) ?? false;\n },\n get isMetric(): boolean {\n const { region } = this;\n switch (region) {\n case 'US': // USA\n case 'LR': // Liberia\n case 'MM': // Myanmar\n return false;\n }\n return true;\n },\n get locale(): string {\n if (!Platform.isDOMAvailable) {\n return '';\n }\n const locale =\n navigator.language ||\n navigator['systemLanguage'] ||\n navigator['browserLanguage'] ||\n navigator['userLanguage'] ||\n this.locales[0];\n return locale;\n },\n get locales(): string[] {\n if (!Platform.isDOMAvailable) {\n return [];\n }\n const { languages = [] } = navigator;\n return Array.from(languages);\n },\n get timezone(): string {\n const defaultTimeZone = 'Etc/UTC';\n if (typeof Intl === 'undefined') {\n return defaultTimeZone;\n }\n return Intl.DateTimeFormat().resolvedOptions().timeZone || defaultTimeZone;\n },\n get isoCurrencyCodes(): string[] {\n // TODO(Bacon): Add this - very low priority\n return [];\n },\n get region(): string | null {\n // There is no way to obtain the current region, as is possible on native.\n // Instead, use the country-code from the locale when possible (e.g. \"en-US\").\n const { locale } = this;\n const [, ...suffixes] = typeof locale === 'string' ? locale.split('-') : [];\n for (const suffix of suffixes) {\n if (suffix.length === 2) {\n return suffix.toUpperCase();\n }\n }\n return null;\n },\n\n getLocales(): Locale[] {\n const locales = getNavigatorLocales();\n return locales?.map((languageTag) => {\n // TextInfo is an experimental API that is not available in all browsers.\n // We might want to consider using a locale lookup table instead.\n const locale =\n typeof Intl !== 'undefined'\n ? (new Intl.Locale(languageTag) as unknown as ExtendedLocale)\n : { region: null, textInfo: null, language: null };\n const { region, textInfo, language } = locale;\n\n // Properties added only for compatibility with native, use `toLocaleString` instead.\n const digitGroupingSeparator =\n Array.from((10000).toLocaleString(languageTag)).filter((c) => c > '9' || c < '0')[0] ||\n null; // using 1e5 instead of 1e4 since for some locales (like pl-PL) 1e4 does not use digit grouping\n const decimalSeparator = (1.1).toLocaleString(languageTag).substring(1, 2);\n\n return {\n languageTag,\n languageCode: language || languageTag.split('-')[0] || 'en',\n textDirection: (textInfo?.direction as 'ltr' | 'rtl') || null,\n digitGroupingSeparator,\n decimalSeparator,\n measurementSystem: null,\n currencyCode: null,\n currencySymbol: null,\n regionCode: region || null,\n };\n });\n },\n getCalendars(): Calendar[] {\n const locale = ((typeof Intl !== 'undefined'\n ? Intl.DateTimeFormat().resolvedOptions()\n : null) ?? null) as unknown as null | ExtendedLocale;\n return [\n {\n calendar: ((locale?.calendar || locale?.calendars?.[0]) as CalendarIdentifier) || null,\n timeZone: locale?.timeZone || locale?.timeZones?.[0] || null,\n uses24hourClock: (locale?.hourCycle || locale?.hourCycles?.[0])?.startsWith('h2') ?? null, //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle\n firstWeekday: locale?.weekInfo?.firstDay || null,\n },\n ];\n },\n async getLocalizationAsync(): Promise<Omit<Localization, 'getCalendars' | 'getLocales'>> {\n const {\n currency,\n decimalSeparator,\n digitGroupingSeparator,\n isoCurrencyCodes,\n isMetric,\n isRTL,\n locale,\n locales,\n region,\n timezone,\n } = this;\n return {\n currency,\n decimalSeparator,\n digitGroupingSeparator,\n isoCurrencyCodes,\n isMetric,\n isRTL,\n locale,\n locales,\n region,\n timezone,\n };\n },\n};\n"]}
1
+ {"version":3,"file":"ExpoLocalization.js","sourceRoot":"","sources":["../src/ExpoLocalization.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,QAAQ,EAAgB,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,MAAM,mBAAmB,GAAG,GAAG,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;SACT,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["/* eslint-env browser */\nimport { Platform, Subscription } from 'expo-modules-core';\nimport * as rtlDetect from 'rtl-detect';\n\nimport { Localization, Calendar, Locale, CalendarIdentifier } from './Localization.types';\n\nconst getNavigatorLocales = () => {\n return Platform.isDOMAvailable ? navigator.languages || [navigator.language] : [];\n};\n\ntype ExtendedLocale = Intl.Locale &\n // typescript definitions for navigator language don't include some modern Intl properties\n Partial<{\n textInfo: { direction: 'ltr' | 'rtl' };\n timeZones: string[];\n weekInfo: { firstDay: number };\n hourCycles: string[];\n timeZone: string;\n calendars: string[];\n }>;\n\nconst WEB_LANGUAGE_CHANGE_EVENT = 'languagechange';\n\nexport function addLocaleListener(listener: (event) => void): Subscription {\n addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);\n return {\n remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),\n };\n}\n\nexport function addCalendarListener(listener: (event) => void): Subscription {\n addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);\n return {\n remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),\n };\n}\nexport function removeSubscription(subscription: Subscription) {\n subscription.remove();\n}\n\nexport default {\n get currency(): string | null {\n // TODO: Add support\n return null;\n },\n get decimalSeparator(): string {\n return (1.1).toLocaleString().substring(1, 2);\n },\n get digitGroupingSeparator(): string {\n const value = (1000).toLocaleString();\n return value.length === 5 ? value.substring(1, 2) : '';\n },\n get isRTL(): boolean {\n return rtlDetect.isRtlLang(this.locale) ?? false;\n },\n get isMetric(): boolean {\n const { region } = this;\n switch (region) {\n case 'US': // USA\n case 'LR': // Liberia\n case 'MM': // Myanmar\n return false;\n }\n return true;\n },\n get locale(): string {\n if (!Platform.isDOMAvailable) {\n return '';\n }\n const locale =\n navigator.language ||\n navigator['systemLanguage'] ||\n navigator['browserLanguage'] ||\n navigator['userLanguage'] ||\n this.locales[0];\n return locale;\n },\n get locales(): string[] {\n if (!Platform.isDOMAvailable) {\n return [];\n }\n const { languages = [] } = navigator;\n return Array.from(languages);\n },\n get timezone(): string {\n const defaultTimeZone = 'Etc/UTC';\n if (typeof Intl === 'undefined') {\n return defaultTimeZone;\n }\n return Intl.DateTimeFormat().resolvedOptions().timeZone || defaultTimeZone;\n },\n get isoCurrencyCodes(): string[] {\n // TODO(Bacon): Add this - very low priority\n return [];\n },\n get region(): string | null {\n // There is no way to obtain the current region, as is possible on native.\n // Instead, use the country-code from the locale when possible (e.g. \"en-US\").\n const { locale } = this;\n const [, ...suffixes] = typeof locale === 'string' ? locale.split('-') : [];\n for (const suffix of suffixes) {\n if (suffix.length === 2) {\n return suffix.toUpperCase();\n }\n }\n return null;\n },\n\n getLocales(): Locale[] {\n const locales = getNavigatorLocales();\n return locales?.map((languageTag) => {\n // TextInfo is an experimental API that is not available in all browsers.\n // We might want to consider using a locale lookup table instead.\n const locale =\n typeof Intl !== 'undefined'\n ? (new Intl.Locale(languageTag) as unknown as ExtendedLocale)\n : { region: null, textInfo: null, language: null };\n const { region, textInfo, language } = locale;\n\n // Properties added only for compatibility with native, use `toLocaleString` instead.\n const digitGroupingSeparator =\n Array.from((10000).toLocaleString(languageTag)).filter((c) => c > '9' || c < '0')[0] ||\n null; // using 1e5 instead of 1e4 since for some locales (like pl-PL) 1e4 does not use digit grouping\n const decimalSeparator = (1.1).toLocaleString(languageTag).substring(1, 2);\n\n return {\n languageTag,\n languageCode: language || languageTag.split('-')[0] || 'en',\n textDirection: (textInfo?.direction as 'ltr' | 'rtl') || null,\n digitGroupingSeparator,\n decimalSeparator,\n measurementSystem: null,\n currencyCode: null,\n currencySymbol: null,\n regionCode: region || null,\n };\n });\n },\n getCalendars(): Calendar[] {\n const locale = ((typeof Intl !== 'undefined'\n ? Intl.DateTimeFormat().resolvedOptions()\n : null) ?? null) as unknown as null | ExtendedLocale;\n return [\n {\n calendar: ((locale?.calendar || locale?.calendars?.[0]) as CalendarIdentifier) || null,\n timeZone: locale?.timeZone || locale?.timeZones?.[0] || null,\n uses24hourClock: (locale?.hourCycle || locale?.hourCycles?.[0])?.startsWith('h2') ?? null, //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle\n firstWeekday: locale?.weekInfo?.firstDay || null,\n },\n ];\n },\n\n async getLocalizationAsync(): Promise<Omit<Localization, 'getCalendars' | 'getLocales'>> {\n const {\n currency,\n decimalSeparator,\n digitGroupingSeparator,\n isoCurrencyCodes,\n isMetric,\n isRTL,\n locale,\n locales,\n region,\n timezone,\n } = this;\n return {\n currency,\n decimalSeparator,\n digitGroupingSeparator,\n isoCurrencyCodes,\n isMetric,\n isRTL,\n locale,\n locales,\n region,\n timezone,\n };\n },\n};\n"]}
@@ -1,3 +1,7 @@
1
- declare const _default: any;
2
- export default _default;
1
+ import { Subscription } from 'expo-modules-core';
2
+ declare const ExpoLocalizationModule: any;
3
+ export declare function addLocaleListener(listener: (event: any) => void): Subscription;
4
+ export declare function addCalendarListener(listener: (event: any) => void): Subscription;
5
+ export declare function removeSubscription(subscription: Subscription): void;
6
+ export default ExpoLocalizationModule;
3
7
  //# sourceMappingURL=ExpoLocalization.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLocalization.native.d.ts","sourceRoot":"","sources":["../src/ExpoLocalization.native.ts"],"names":[],"mappings":";AAEA,wBAAuD"}
1
+ {"version":3,"file":"ExpoLocalization.native.d.ts","sourceRoot":"","sources":["../src/ExpoLocalization.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAEpF,QAAA,MAAM,sBAAsB,KAA0C,CAAC;AAGvE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,GAAG,YAAY,CAEzE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,GAAG,YAAY,CAE3E;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,QAE5D;AAED,eAAe,sBAAsB,CAAC"}
@@ -1,3 +1,14 @@
1
- import { requireNativeModule } from 'expo-modules-core';
2
- export default requireNativeModule('ExpoLocalization');
1
+ import { EventEmitter, requireNativeModule } from 'expo-modules-core';
2
+ const ExpoLocalizationModule = requireNativeModule('ExpoLocalization');
3
+ const emitter = new EventEmitter(ExpoLocalizationModule);
4
+ export function addLocaleListener(listener) {
5
+ return emitter.addListener('onLocaleSettingsChanged', listener);
6
+ }
7
+ export function addCalendarListener(listener) {
8
+ return emitter.addListener('onCalendarSettingsChanged', listener);
9
+ }
10
+ export function removeSubscription(subscription) {
11
+ return emitter.removeSubscription(subscription);
12
+ }
13
+ export default ExpoLocalizationModule;
3
14
  //# sourceMappingURL=ExpoLocalization.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLocalization.native.js","sourceRoot":"","sources":["../src/ExpoLocalization.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAe,mBAAmB,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\nexport default requireNativeModule('ExpoLocalization');\n"]}
1
+ {"version":3,"file":"ExpoLocalization.native.js","sourceRoot":"","sources":["../src/ExpoLocalization.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;AACvE,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAEzD,MAAM,UAAU,iBAAiB,CAAC,QAAyB;IACzD,OAAO,OAAO,CAAC,WAAW,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAyB;IAC3D,OAAO,OAAO,CAAC,WAAW,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAA0B;IAC3D,OAAO,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,eAAe,sBAAsB,CAAC","sourcesContent":["import { EventEmitter, Subscription, requireNativeModule } from 'expo-modules-core';\n\nconst ExpoLocalizationModule = requireNativeModule('ExpoLocalization');\nconst emitter = new EventEmitter(ExpoLocalizationModule);\n\nexport function addLocaleListener(listener: (event) => void): Subscription {\n return emitter.addListener('onLocaleSettingsChanged', listener);\n}\n\nexport function addCalendarListener(listener: (event) => void): Subscription {\n return emitter.addListener('onCalendarSettingsChanged', listener);\n}\n\nexport function removeSubscription(subscription: Subscription) {\n return emitter.removeSubscription(subscription);\n}\n\nexport default ExpoLocalizationModule;\n"]}
@@ -107,6 +107,41 @@ export declare const getLocales: () => import("./Localization.types").Locale[];
107
107
  ]`
108
108
  */
109
109
  export declare const getCalendars: () => import("./Localization.types").Calendar[];
110
+ /**
111
+ * A hook providing a list of user's locales, returned as an array of objects of type `Locale`.
112
+ * Guaranteed to contain at least 1 element.
113
+ * These are returned in the order the user defines in their device settings.
114
+ * On the web currency and measurements systems are not provided, instead returned as null.
115
+ * If needed, you can infer them from the current region using a lookup table.
116
+ * If the OS settings change, the hook will rerender with a new list of locales.
117
+ * @example `[{
118
+ "languageTag": "pl-PL",
119
+ "languageCode": "pl",
120
+ "textDirection": "ltr",
121
+ "digitGroupingSeparator": " ",
122
+ "decimalSeparator": ",",
123
+ "measurementSystem": "metric",
124
+ "currencyCode": "PLN",
125
+ "currencySymbol": "zł",
126
+ "regionCode": "PL"
127
+ }]`
128
+ */
129
+ export declare function useLocales(): import("./Localization.types").Locale[];
130
+ /**
131
+ * A hook providing a list of user's preferred calendars, returned as an array of objects of type `Calendar`.
132
+ * Guaranteed to contain at least 1 element.
133
+ * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
134
+ * If the OS settings change, the hook will rerender with a new list of calendars.
135
+ * @example `[
136
+ {
137
+ "calendar": "gregory",
138
+ "timeZone": "Europe/Warsaw",
139
+ "uses24hourClock": true,
140
+ "firstWeekday": 1
141
+ }
142
+ ]`
143
+ */
144
+ export declare function useCalendars(): import("./Localization.types").Calendar[];
110
145
  /**
111
146
  * Get the latest native values from the device. Locale can be changed on some Android devices
112
147
  * without resetting the app.
@@ -1 +1 @@
1
- {"version":3,"file":"Localization.d.ts","sourceRoot":"","sources":["../src/Localization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,cAAc,sBAAsB,CAAC;AAGrC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,eAA4B,CAAC;AAGlD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAoC,CAAC;AAGlE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAA0C,CAAC;AAG9E;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAoC,CAAC;AAGlE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAA4B,CAAC;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,SAAyB,CAAC;AAG5C;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,QAA0B,CAAC;AAG9C;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,UAA2B,CAAC;AAGhD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,eAA0B,CAAC;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,+CAA8B,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,iDAAgC,CAAC;AAG1D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,CAElE"}
1
+ {"version":3,"file":"Localization.d.ts","sourceRoot":"","sources":["../src/Localization.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,cAAc,sBAAsB,CAAC;AAGrC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,eAA4B,CAAC;AAGlD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAoC,CAAC;AAGlE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAA0C,CAAC;AAG9E;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAoC,CAAC;AAGlE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAA4B,CAAC;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,SAAyB,CAAC;AAG5C;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,QAA0B,CAAC;AAG9C;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,UAA2B,CAAC;AAGhD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,eAA0B,CAAC;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,+CAA8B,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,iDAAgC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,4CAUzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,8CAU3B;AAGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,CAElE"}
@@ -1,4 +1,5 @@
1
- import ExpoLocalization from './ExpoLocalization';
1
+ import { useEffect, useReducer, useMemo } from 'react';
2
+ import ExpoLocalization, { addCalendarListener, addLocaleListener, removeSubscription, } from './ExpoLocalization';
2
3
  export * from './Localization.types';
3
4
  // @needsAudit
4
5
  /**
@@ -117,6 +118,61 @@ export const getLocales = ExpoLocalization.getLocales;
117
118
  ]`
118
119
  */
119
120
  export const getCalendars = ExpoLocalization.getCalendars;
121
+ /**
122
+ * A hook providing a list of user's locales, returned as an array of objects of type `Locale`.
123
+ * Guaranteed to contain at least 1 element.
124
+ * These are returned in the order the user defines in their device settings.
125
+ * On the web currency and measurements systems are not provided, instead returned as null.
126
+ * If needed, you can infer them from the current region using a lookup table.
127
+ * If the OS settings change, the hook will rerender with a new list of locales.
128
+ * @example `[{
129
+ "languageTag": "pl-PL",
130
+ "languageCode": "pl",
131
+ "textDirection": "ltr",
132
+ "digitGroupingSeparator": " ",
133
+ "decimalSeparator": ",",
134
+ "measurementSystem": "metric",
135
+ "currencyCode": "PLN",
136
+ "currencySymbol": "zł",
137
+ "regionCode": "PL"
138
+ }]`
139
+ */
140
+ export function useLocales() {
141
+ const [key, invalidate] = useReducer((k) => k + 1, 0);
142
+ const locales = useMemo(() => getLocales(), [key]);
143
+ useEffect(() => {
144
+ const subscription = addLocaleListener(invalidate);
145
+ return () => {
146
+ removeSubscription(subscription);
147
+ };
148
+ }, []);
149
+ return locales;
150
+ }
151
+ /**
152
+ * A hook providing a list of user's preferred calendars, returned as an array of objects of type `Calendar`.
153
+ * Guaranteed to contain at least 1 element.
154
+ * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
155
+ * If the OS settings change, the hook will rerender with a new list of calendars.
156
+ * @example `[
157
+ {
158
+ "calendar": "gregory",
159
+ "timeZone": "Europe/Warsaw",
160
+ "uses24hourClock": true,
161
+ "firstWeekday": 1
162
+ }
163
+ ]`
164
+ */
165
+ export function useCalendars() {
166
+ const [key, invalidate] = useReducer((k) => k + 1, 0);
167
+ const calendars = useMemo(() => getCalendars(), [key]);
168
+ useEffect(() => {
169
+ const subscription = addCalendarListener(invalidate);
170
+ return () => {
171
+ removeSubscription(subscription);
172
+ };
173
+ }, []);
174
+ return calendars;
175
+ }
120
176
  // @needsAudit
121
177
  /**
122
178
  * Get the latest native values from the device. Locale can be changed on some Android devices
@@ -1 +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AAY,CAAC;AAE1D,cAAc;AACd;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,OAAO,MAAM,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import ExpoLocalization from './ExpoLocalization';\nimport { Localization } from './Localization.types';\nexport * from './Localization.types';\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Three-character ISO 4217 currency code. Returns `null` on web.\n *\n * @example `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\nexport const currency = ExpoLocalization.currency;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Decimal separator used for formatting numbers.\n *\n * @example `','`, `'.'`\n */\nexport const decimalSeparator = ExpoLocalization.decimalSeparator;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Digit grouping separator used when formatting numbers larger than 1000.\n *\n * @example `'.'`, `''`, `','`\n */\nexport const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * A list of all the supported language ISO codes.\n */\nexport const isoCurrencyCodes = ExpoLocalization.isoCurrencyCodes;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Boolean value that indicates whether the system uses the metric system.\n * On Android and web, this is inferred from the current region.\n */\nexport const isMetric = ExpoLocalization.isMetric;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Returns if the system's language is written from Right-to-Left.\n * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).\n *\n * Returns `false` in Server Side Rendering (SSR) environments.\n */\nexport const isRTL = ExpoLocalization.isRTL;\n\n// @needsAudit\n/**\n * Consider using Localization.getLocales() for a list of user preferred locales instead.\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),\n * consisting of a two-character language code and optional script, region and variant codes.\n *\n * @example `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`\n */\nexport const locale = ExpoLocalization.locale;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * List of all the native languages provided by the user settings.\n * These are returned in the order the user defines in their device settings.\n *\n * @example `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`\n */\nexport const locales = ExpoLocalization.locales;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * The current time zone in display format.\n * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a\n * better estimation you could use the moment-timezone package but it will add significant bloat to\n * your website's bundle size.\n *\n * @example `'America/Los_Angeles'`\n */\nexport const timezone = ExpoLocalization.timezone;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * The region code for your device that comes from the Region setting under Language & Region on iOS.\n * This value is always available on iOS, but might return `null` on Android or web.\n *\n * @example `'US'`, `'NZ'`, `null`\n */\nexport const region = ExpoLocalization.region;\n\n/**\n * List of user's locales, returned as an array of objects of type `Locale`.\n * Guaranteed to contain at least 1 element.\n * These are returned in the order the user defines in their device settings.\n * On the web currency and measurements systems are not provided, instead returned as null.\n * If needed, you can infer them from the current region using a lookup table.\n * @example `[{\n \"languageTag\": \"pl-PL\",\n \"languageCode\": \"pl\",\n \"textDirection\": \"ltr\",\n \"digitGroupingSeparator\": \" \",\n \"decimalSeparator\": \",\",\n \"measurementSystem\": \"metric\",\n \"currencyCode\": \"PLN\",\n \"currencySymbol\": \"zł\",\n \"regionCode\": \"PL\"\n }]`\n */\nexport const getLocales = ExpoLocalization.getLocales;\n\n/**\n * List of user's preferred calendars, returned as an array of objects of type `Calendar`.\n * Guaranteed to contain at least 1 element.\n * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.\n * @example `[\n {\n \"calendar\": \"gregory\",\n \"timeZone\": \"Europe/Warsaw\",\n \"uses24hourClock\": true,\n \"firstWeekday\": 1\n }\n ]`\n */\nexport const getCalendars = ExpoLocalization.getCalendars;\n\n// @needsAudit\n/**\n * Get the latest native values from the device. Locale can be changed on some Android devices\n * without resetting the app.\n * > On iOS, changing the locale will cause the device to reset meaning the constants will always be\n * correct.\n *\n * @example\n * ```ts\n * // When the app returns from the background on Android...\n *\n * const { locale } = await Localization.getLocalizationAsync();\n * ```\n * @deprecated\n * Use Localization.getLocales() or Localization.getCalendars() instead.\n */\nexport async function getLocalizationAsync(): Promise<Localization> {\n return await ExpoLocalization.getLocalizationAsync();\n}\n"]}
1
+ {"version":3,"file":"Localization.js","sourceRoot":"","sources":["../src/Localization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,gBAAgB,EAAE,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,sBAAsB,CAAC;AAErC,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAElD,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;AAElE,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC;AAE9E,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;AAElE,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAElD,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC;AAE5C,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC;AAE9C,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AE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACrD,OAAO,GAAG,EAAE;YACV,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,OAAO,MAAM,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import { useEffect, useReducer, useMemo } from 'react';\n\nimport ExpoLocalization, {\n addCalendarListener,\n addLocaleListener,\n removeSubscription,\n} from './ExpoLocalization';\nimport { Localization } from './Localization.types';\nexport * from './Localization.types';\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Three-character ISO 4217 currency code. Returns `null` on web.\n *\n * @example `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\nexport const currency = ExpoLocalization.currency;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Decimal separator used for formatting numbers.\n *\n * @example `','`, `'.'`\n */\nexport const decimalSeparator = ExpoLocalization.decimalSeparator;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Digit grouping separator used when formatting numbers larger than 1000.\n *\n * @example `'.'`, `''`, `','`\n */\nexport const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * A list of all the supported language ISO codes.\n */\nexport const isoCurrencyCodes = ExpoLocalization.isoCurrencyCodes;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Boolean value that indicates whether the system uses the metric system.\n * On Android and web, this is inferred from the current region.\n */\nexport const isMetric = ExpoLocalization.isMetric;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * Returns if the system's language is written from Right-to-Left.\n * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).\n *\n * Returns `false` in Server Side Rendering (SSR) environments.\n */\nexport const isRTL = ExpoLocalization.isRTL;\n\n// @needsAudit\n/**\n * Consider using Localization.getLocales() for a list of user preferred locales instead.\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),\n * consisting of a two-character language code and optional script, region and variant codes.\n *\n * @example `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`\n */\nexport const locale = ExpoLocalization.locale;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * List of all the native languages provided by the user settings.\n * These are returned in the order the user defines in their device settings.\n *\n * @example `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`\n */\nexport const locales = ExpoLocalization.locales;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * The current time zone in display format.\n * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a\n * better estimation you could use the moment-timezone package but it will add significant bloat to\n * your website's bundle size.\n *\n * @example `'America/Los_Angeles'`\n */\nexport const timezone = ExpoLocalization.timezone;\n\n// @needsAudit\n/**\n * @deprecated Use Localization.getLocales() instead.\n * The region code for your device that comes from the Region setting under Language & Region on iOS.\n * This value is always available on iOS, but might return `null` on Android or web.\n *\n * @example `'US'`, `'NZ'`, `null`\n */\nexport const region = ExpoLocalization.region;\n\n/**\n * List of user's locales, returned as an array of objects of type `Locale`.\n * Guaranteed to contain at least 1 element.\n * These are returned in the order the user defines in their device settings.\n * On the web currency and measurements systems are not provided, instead returned as null.\n * If needed, you can infer them from the current region using a lookup table.\n * @example `[{\n \"languageTag\": \"pl-PL\",\n \"languageCode\": \"pl\",\n \"textDirection\": \"ltr\",\n \"digitGroupingSeparator\": \" \",\n \"decimalSeparator\": \",\",\n \"measurementSystem\": \"metric\",\n \"currencyCode\": \"PLN\",\n \"currencySymbol\": \"zł\",\n \"regionCode\": \"PL\"\n }]`\n */\nexport const getLocales = ExpoLocalization.getLocales;\n\n/**\n * List of user's preferred calendars, returned as an array of objects of type `Calendar`.\n * Guaranteed to contain at least 1 element.\n * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.\n * @example `[\n {\n \"calendar\": \"gregory\",\n \"timeZone\": \"Europe/Warsaw\",\n \"uses24hourClock\": true,\n \"firstWeekday\": 1\n }\n ]`\n */\nexport const getCalendars = ExpoLocalization.getCalendars;\n\n/**\n * A hook providing a list of user's locales, returned as an array of objects of type `Locale`.\n * Guaranteed to contain at least 1 element.\n * These are returned in the order the user defines in their device settings.\n * On the web currency and measurements systems are not provided, instead returned as null.\n * If needed, you can infer them from the current region using a lookup table.\n * If the OS settings change, the hook will rerender with a new list of locales.\n * @example `[{\n \"languageTag\": \"pl-PL\",\n \"languageCode\": \"pl\",\n \"textDirection\": \"ltr\",\n \"digitGroupingSeparator\": \" \",\n \"decimalSeparator\": \",\",\n \"measurementSystem\": \"metric\",\n \"currencyCode\": \"PLN\",\n \"currencySymbol\": \"zł\",\n \"regionCode\": \"PL\"\n }]`\n */\nexport function useLocales() {\n const [key, invalidate] = useReducer((k) => k + 1, 0);\n const locales = useMemo(() => getLocales(), [key]);\n useEffect(() => {\n const subscription = addLocaleListener(invalidate);\n return () => {\n removeSubscription(subscription);\n };\n }, []);\n return locales;\n}\n\n/**\n * A hook providing a list of user's preferred calendars, returned as an array of objects of type `Calendar`.\n * Guaranteed to contain at least 1 element.\n * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.\n * If the OS settings change, the hook will rerender with a new list of calendars.\n * @example `[\n {\n \"calendar\": \"gregory\",\n \"timeZone\": \"Europe/Warsaw\",\n \"uses24hourClock\": true,\n \"firstWeekday\": 1\n }\n ]`\n */\nexport function useCalendars() {\n const [key, invalidate] = useReducer((k) => k + 1, 0);\n const calendars = useMemo(() => getCalendars(), [key]);\n useEffect(() => {\n const subscription = addCalendarListener(invalidate);\n return () => {\n removeSubscription(subscription);\n };\n }, []);\n return calendars;\n}\n\n// @needsAudit\n/**\n * Get the latest native values from the device. Locale can be changed on some Android devices\n * without resetting the app.\n * > On iOS, changing the locale will cause the device to reset meaning the constants will always be\n * correct.\n *\n * @example\n * ```ts\n * // When the app returns from the background on Android...\n *\n * const { locale } = await Localization.getLocalizationAsync();\n * ```\n * @deprecated\n * Use Localization.getLocales() or Localization.getCalendars() instead.\n */\nexport async function getLocalizationAsync(): Promise<Localization> {\n return await ExpoLocalization.getLocalizationAsync();\n}\n"]}
@@ -107,8 +107,6 @@ export type Locale = {
107
107
  textDirection: 'ltr' | 'rtl' | null;
108
108
  /**
109
109
  * The measurement system used in the locale.
110
- * On iOS is one of `'metric'`, `'us'`. On Android is one of `'metric'`, `'us'`, `'uk'`.
111
- *
112
110
  * 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
111
  * Ask for user preferences if possible.
114
112
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Localization.types.d.ts","sourceRoot":"","sources":["../src/Localization.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,EAAE,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wG;IACxG,YAAY,iBAAiB;IAC7B,oCAAoC;IACpC,gBAAgB,qBAAqB;IACrC,+EAA+E;IAC/E,OAAO,YAAY;IACnB,iCAAiC;IACjC,QAAQ,aAAa;IACrB,uBAAuB;IACvB,OAAO,YAAY;IACnB,0CAA0C;IAC1C,GAAG,QAAQ;CACZ;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB;;;;;;OAMG;IACH,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"Localization.types.d.ts","sourceRoot":"","sources":["../src/Localization.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU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B,0CAA0C;IAC1C,GAAG,QAAQ;CACZ;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB;;;;;;OAMG;IACH,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Localization.types.js","sourceRoot":"","sources":["../src/Localization.types.ts"],"names":[],"mappings":"AAuHA;;GAEG;AACH,MAAM,CAAN,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,yCAAU,CAAA;IACV,yCAAU,CAAA;IACV,2CAAW,CAAA;IACX,+CAAa,CAAA;IACb,6CAAY,CAAA;IACZ,yCAAU,CAAA;IACV,6CAAY,CAAA;AACd,CAAC,EARW,OAAO,KAAP,OAAO,QAQlB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAuCX;AAvCD,WAAY,kBAAkB;IAC5B,6BAA6B;IAC7B,2CAAqB,CAAA;IACrB,mCAAmC;IACnC,yCAAmB,CAAA;IACnB,sBAAsB;IACtB,uCAAiB,CAAA;IACjB,kCAAkC;IAClC,qCAAe,CAAA;IACf,+DAA+D;IAC/D,yCAAmB,CAAA;IACnB,6DAA6D;IAC7D,2CAAqB,CAAA;IACrB,yBAAyB;IACzB,yCAAmB,CAAA;IACnB,iCAAiC;IACjC,2CAAqB,CAAA;IACrB,kCAAkC;IAClC,uCAAiB,CAAA;IACjB,sBAAsB;IACtB,uCAAiB,CAAA;IACjB,uBAAuB;IACvB,yCAAmB,CAAA;IACnB,kGAAkG;IAClG,qDAA+B,CAAA;IAC/B,8CAA8C;IAC9C,mDAA6B,CAAA;IAC7B,wGAAwG;IACxG,mDAA6B,CAAA;IAC7B,oCAAoC;IACpC,2DAAqC,CAAA;IACrC,+EAA+E;IAC/E,yCAAmB,CAAA;IACnB,iCAAiC;IACjC,2CAAqB,CAAA;IACrB,uBAAuB;IACvB,yCAAmB,CAAA;IACnB,0CAA0C;IAC1C,iCAAW,CAAA;AACb,CAAC,EAvCW,kBAAkB,KAAlB,kBAAkB,QAuC7B","sourcesContent":["// @needsAudit\nexport type Localization = {\n /**\n * Three-character ISO 4217 currency code. Returns `null` on web.\n *\n * @example `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\n currency: string | null;\n /**\n * Decimal separator used for formatting numbers.\n *\n * @example `','`, `'.'`\n */\n decimalSeparator: string;\n /**\n * Digit grouping separator used when formatting numbers larger than 1000.\n *\n * @example `'.'`, `''`, `','`\n */\n digitGroupingSeparator: string;\n /**\n * A list of all the supported language ISO codes.\n */\n isoCurrencyCodes: string[];\n /**\n * Boolean value that indicates whether the system uses the metric system.\n * On Android and web, this is inferred from the current region.\n */\n isMetric: boolean;\n /**\n * Returns if the system's language is written from Right-to-Left.\n * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).\n *\n * Returns `false` in Server Side Rendering (SSR) environments.\n */\n isRTL: boolean;\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),\n * consisting of a two-character language code and optional script, region and variant codes.\n *\n * @example `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`\n */\n locale: string;\n /**\n * List of all the native languages provided by the user settings.\n * These are returned in the order that the user defined in the device settings.\n *\n * @example `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`\n */\n locales: string[];\n /**\n * The region code for your device that comes from the Region setting under Language & Region on iOS.\n * This value is always available on iOS, but might return `null` on Android or web.\n *\n * @example `'US'`, `'NZ'`, `null`\n */\n region: string | null;\n /**\n * The current time zone in display format.\n * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a\n * better estimation you could use the moment-timezone package but it will add significant bloat to\n * your website's bundle size.\n *\n * @example `'America/Los_Angeles'`\n */\n timezone: string;\n};\n\nexport type Locale = {\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.\n * @example `'en-US'`, `'es-419'`, `'pl-PL'`.\n */\n languageTag: string;\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.\n * @example `'en'`, `'es'`, `'pl'`.\n */\n languageCode: string;\n /**\n * 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).\n */\n regionCode: string | null;\n /**\n * Currency code for the locale.\n * Is `null` on Web, use a table lookup based on region instead.\n * @example `'USD'`, `'EUR'`, `'PLN'`.\n */\n currencyCode: string | null;\n /**\n * Currency symbol for the locale.\n * Is `null` on Web, use a table lookup based on region (if available) instead.\n * @example `'$'`, `'€'`, `'zł'`.\n */\n currencySymbol: string | null;\n /**\n * Decimal separator used for formatting numbers with fractional parts.\n * @example `'.'`, `','`.\n */\n decimalSeparator: string | null;\n /**\n * Digit grouping separator used for formatting large numbers.\n * @example `'.'`, `','`.\n */\n digitGroupingSeparator: string | null;\n /**\n * 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.\n */\n textDirection: 'ltr' | 'rtl' | null;\n /**\n * The measurement system used in the locale.\n * On iOS is one of `'metric'`, `'us'`. On Android is one of `'metric'`, `'us'`, `'uk'`.\n *\n * Is `null` on Web, as user chosen measurement system is not exposed on the web and using locale to determine measurement systems is unreliable.\n * Ask for user preferences if possible.\n */\n measurementSystem: `metric` | `us` | `uk` | null;\n};\n\n/**\n * An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.\n */\nexport enum Weekday {\n SUNDAY = 1,\n MONDAY = 2,\n TUESDAY = 3,\n WEDNESDAY = 4,\n THURSDAY = 5,\n FRIDAY = 6,\n SATURDAY = 7,\n}\n\n/**\n * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).\n * Gregorian calendar is aliased and can be referred to as both `CalendarIdentifier.GREGORIAN` and `CalendarIdentifier.GREGORY`.\n */\nexport enum CalendarIdentifier {\n /** Thai Buddhist calendar */\n BUDDHIST = 'buddhist',\n /** Traditional Chinese calendar */\n CHINESE = 'chinese',\n /** Coptic calendar */\n COPTIC = 'coptic',\n /** Traditional Korean calendar */\n DANGI = 'dangi',\n /** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */\n ETHIOAA = 'ethioaa',\n /** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */\n ETHIOPIC = 'ethiopic',\n /** Gregorian calendar */\n GREGORY = 'gregory',\n /** Gregorian calendar (alias) */\n GREGORIAN = 'gregory',\n /** Traditional Hebrew calendar */\n HEBREW = 'hebrew',\n /** Indian calendar */\n INDIAN = 'indian',\n /** Islamic calendar */\n ISLAMIC = 'islamic',\n /** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */\n ISLAMIC_CIVIL = 'islamic-civil',\n /** Islamic calendar, Saudi Arabia sighting */\n ISLAMIC_RGSA = 'islamic-rgsa',\n /**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */\n ISLAMIC_TBLA = 'islamic-tbla',\n /** Islamic calendar, Umm al-Qura */\n ISLAMIC_UMALQURA = 'islamic-umalqura',\n /** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */\n ISO8601 = 'iso8601',\n /** Japanese imperial calendar */\n JAPANESE = 'japanese',\n /** Persian calendar */\n PERSIAN = 'persian',\n /** Civil (algorithmic) Arabic calendar */\n ROC = 'roc',\n}\n\nexport type Calendar = {\n /**\n * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).\n *\n * On Android is limited to one of device's [available calendar types](https://developer.android.com/reference/java/util/Calendar#getAvailableCalendarTypes()).\n *\n * 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.\n */\n calendar: CalendarIdentifier | null;\n /**\n * True when current device settings use 24 hour time format.\n * 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.\n */\n uses24hourClock: boolean | null;\n /**\n * The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.\n * 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.\n * @example `1`, `7`.\n */\n firstWeekday: Weekday | null;\n /**\n * Time zone for the calendar. Can be `null` on Web.\n * @example `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.\n */\n timeZone: string | null;\n};\n"]}
1
+ {"version":3,"file":"Localization.types.js","sourceRoot":"","sources":["../src/Localization.types.ts"],"names":[],"mappings":"AAqHA;;GAEG;AACH,MAAM,CAAN,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,yCAAU,CAAA;IACV,yCAAU,CAAA;IACV,2CAAW,CAAA;IACX,+CAAa,CAAA;IACb,6CAAY,CAAA;IACZ,yCAAU,CAAA;IACV,6CAAY,CAAA;AACd,CAAC,EARW,OAAO,KAAP,OAAO,QAQlB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAuCX;AAvCD,WAAY,kBAAkB;IAC5B,6BAA6B;IAC7B,2CAAqB,CAAA;IACrB,mCAAmC;IACnC,yCAAmB,CAAA;IACnB,sBAAsB;IACtB,uCAAiB,CAAA;IACjB,kCAAkC;IAClC,qCAAe,CAAA;IACf,+DAA+D;IAC/D,yCAAmB,CAAA;IACnB,6DAA6D;IAC7D,2CAAqB,CAAA;IACrB,yBAAyB;IACzB,yCAAmB,CAAA;IACnB,iCAAiC;IACjC,2CAAqB,CAAA;IACrB,kCAAkC;IAClC,uCAAiB,CAAA;IACjB,sBAAsB;IACtB,uCAAiB,CAAA;IACjB,uBAAuB;IACvB,yCAAmB,CAAA;IACnB,kGAAkG;IAClG,qDAA+B,CAAA;IAC/B,8CAA8C;IAC9C,mDAA6B,CAAA;IAC7B,wGAAwG;IACxG,mDAA6B,CAAA;IAC7B,oCAAoC;IACpC,2DAAqC,CAAA;IACrC,+EAA+E;IAC/E,yCAAmB,CAAA;IACnB,iCAAiC;IACjC,2CAAqB,CAAA;IACrB,uBAAuB;IACvB,yCAAmB,CAAA;IACnB,0CAA0C;IAC1C,iCAAW,CAAA;AACb,CAAC,EAvCW,kBAAkB,KAAlB,kBAAkB,QAuC7B","sourcesContent":["// @needsAudit\nexport type Localization = {\n /**\n * Three-character ISO 4217 currency code. Returns `null` on web.\n *\n * @example `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\n currency: string | null;\n /**\n * Decimal separator used for formatting numbers.\n *\n * @example `','`, `'.'`\n */\n decimalSeparator: string;\n /**\n * Digit grouping separator used when formatting numbers larger than 1000.\n *\n * @example `'.'`, `''`, `','`\n */\n digitGroupingSeparator: string;\n /**\n * A list of all the supported language ISO codes.\n */\n isoCurrencyCodes: string[];\n /**\n * Boolean value that indicates whether the system uses the metric system.\n * On Android and web, this is inferred from the current region.\n */\n isMetric: boolean;\n /**\n * Returns if the system's language is written from Right-to-Left.\n * This can be used to build features like [bidirectional icons](https://material.io/design/usability/bidirectionality.html).\n *\n * Returns `false` in Server Side Rendering (SSR) environments.\n */\n isRTL: boolean;\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),\n * consisting of a two-character language code and optional script, region and variant codes.\n *\n * @example `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`\n */\n locale: string;\n /**\n * List of all the native languages provided by the user settings.\n * These are returned in the order that the user defined in the device settings.\n *\n * @example `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`\n */\n locales: string[];\n /**\n * The region code for your device that comes from the Region setting under Language & Region on iOS.\n * This value is always available on iOS, but might return `null` on Android or web.\n *\n * @example `'US'`, `'NZ'`, `null`\n */\n region: string | null;\n /**\n * The current time zone in display format.\n * On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a\n * better estimation you could use the moment-timezone package but it will add significant bloat to\n * your website's bundle size.\n *\n * @example `'America/Los_Angeles'`\n */\n timezone: string;\n};\n\nexport type Locale = {\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.\n * @example `'en-US'`, `'es-419'`, `'pl-PL'`.\n */\n languageTag: string;\n /**\n * An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.\n * @example `'en'`, `'es'`, `'pl'`.\n */\n languageCode: string;\n /**\n * 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).\n */\n regionCode: string | null;\n /**\n * Currency code for the locale.\n * Is `null` on Web, use a table lookup based on region instead.\n * @example `'USD'`, `'EUR'`, `'PLN'`.\n */\n currencyCode: string | null;\n /**\n * Currency symbol for the locale.\n * Is `null` on Web, use a table lookup based on region (if available) instead.\n * @example `'$'`, `'€'`, `'zł'`.\n */\n currencySymbol: string | null;\n /**\n * Decimal separator used for formatting numbers with fractional parts.\n * @example `'.'`, `','`.\n */\n decimalSeparator: string | null;\n /**\n * Digit grouping separator used for formatting large numbers.\n * @example `'.'`, `','`.\n */\n digitGroupingSeparator: string | null;\n /**\n * 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.\n */\n textDirection: 'ltr' | 'rtl' | null;\n /**\n * The measurement system used in the locale.\n * Is `null` on Web, as user chosen measurement system is not exposed on the web and using locale to determine measurement systems is unreliable.\n * Ask for user preferences if possible.\n */\n measurementSystem: `metric` | `us` | `uk` | null;\n};\n\n/**\n * An enum mapping days of the week in Gregorian calendar to their index as returned by the `firstWeekday` property.\n */\nexport enum Weekday {\n SUNDAY = 1,\n MONDAY = 2,\n TUESDAY = 3,\n WEDNESDAY = 4,\n THURSDAY = 5,\n FRIDAY = 6,\n SATURDAY = 7,\n}\n\n/**\n * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).\n * Gregorian calendar is aliased and can be referred to as both `CalendarIdentifier.GREGORIAN` and `CalendarIdentifier.GREGORY`.\n */\nexport enum CalendarIdentifier {\n /** Thai Buddhist calendar */\n BUDDHIST = 'buddhist',\n /** Traditional Chinese calendar */\n CHINESE = 'chinese',\n /** Coptic calendar */\n COPTIC = 'coptic',\n /** Traditional Korean calendar */\n DANGI = 'dangi',\n /** Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) */\n ETHIOAA = 'ethioaa',\n /** Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) */\n ETHIOPIC = 'ethiopic',\n /** Gregorian calendar */\n GREGORY = 'gregory',\n /** Gregorian calendar (alias) */\n GREGORIAN = 'gregory',\n /** Traditional Hebrew calendar */\n HEBREW = 'hebrew',\n /** Indian calendar */\n INDIAN = 'indian',\n /** Islamic calendar */\n ISLAMIC = 'islamic',\n /** Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) */\n ISLAMIC_CIVIL = 'islamic-civil',\n /** Islamic calendar, Saudi Arabia sighting */\n ISLAMIC_RGSA = 'islamic-rgsa',\n /**Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) */\n ISLAMIC_TBLA = 'islamic-tbla',\n /** Islamic calendar, Umm al-Qura */\n ISLAMIC_UMALQURA = 'islamic-umalqura',\n /** ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) */\n ISO8601 = 'iso8601',\n /** Japanese imperial calendar */\n JAPANESE = 'japanese',\n /** Persian calendar */\n PERSIAN = 'persian',\n /** Civil (algorithmic) Arabic calendar */\n ROC = 'roc',\n}\n\nexport type Calendar = {\n /**\n * The calendar identifier, one of [Unicode calendar types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar).\n *\n * On Android is limited to one of device's [available calendar types](https://developer.android.com/reference/java/util/Calendar#getAvailableCalendarTypes()).\n *\n * 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.\n */\n calendar: CalendarIdentifier | null;\n /**\n * True when current device settings use 24 hour time format.\n * 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.\n */\n uses24hourClock: boolean | null;\n /**\n * The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.\n * 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.\n * @example `1`, `7`.\n */\n firstWeekday: Weekday | null;\n /**\n * Time zone for the calendar. Can be `null` on Web.\n * @example `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.\n */\n timeZone: string | null;\n};\n"]}
@@ -3,6 +3,9 @@
3
3
  import Foundation
4
4
  import ExpoModulesCore
5
5
 
6
+ let LOCALE_SETTINGS_CHANGED = "onLocaleSettingsChanged"
7
+ let CALENDAR_SETTINGS_CHANGED = "onCalendarSettingsChanged"
8
+
6
9
  public class LocalizationModule: Module {
7
10
  public func definition() -> ModuleDefinition {
8
11
  Name("ExpoLocalization")
@@ -24,9 +27,29 @@ public class LocalizationModule: Module {
24
27
  self.setSupportsRTL(enableRTL)
25
28
  }
26
29
  }
30
+
31
+ Events(LOCALE_SETTINGS_CHANGED, CALENDAR_SETTINGS_CHANGED)
32
+
33
+ OnStartObserving {
34
+ NotificationCenter.default.addObserver(
35
+ self,
36
+ selector: #selector(LocalizationModule.localeChanged),
37
+ name: NSLocale.currentLocaleDidChangeNotification, // swiftlint:disable:this legacy_objc_type
38
+ object: nil
39
+ )
40
+ }
41
+
42
+ OnStopObserving {
43
+ NotificationCenter.default.removeObserver(
44
+ self,
45
+ name: NSLocale.currentLocaleDidChangeNotification, // swiftlint:disable:this legacy_objc_type
46
+ object: nil
47
+ )
48
+ }
27
49
  }
28
50
 
29
51
  func isRTLPreferredForCurrentLocale() -> Bool {
52
+ // swiftlint:disable:next legacy_objc_type
30
53
  return NSLocale.characterDirection(forLanguage: NSLocale.preferredLanguages.first ?? "en-US") == NSLocale.LanguageDirection.rightToLeft
31
54
  }
32
55
 
@@ -91,24 +114,46 @@ public class LocalizationModule: Module {
91
114
  }
92
115
  }
93
116
 
117
+ static func getMeasurementSystemForLocale(_ locale: Locale) -> String {
118
+ if #available(iOS 16, *) {
119
+ let measurementSystems = [
120
+ Locale.MeasurementSystem.us: "us",
121
+ Locale.MeasurementSystem.uk: "uk",
122
+ Locale.MeasurementSystem.metric: "metric"
123
+ ]
124
+ return measurementSystems[locale.measurementSystem] ?? "metric"
125
+ }
126
+ return locale.usesMetricSystem ? "metric" : "us"
127
+ }
128
+
94
129
  static func getLocales() -> [[String: Any?]] {
130
+ let userSettingsLocale = Locale.current
131
+
95
132
  return (Locale.preferredLanguages.isEmpty ? [Locale.current.identifier] : Locale.preferredLanguages)
96
133
  .map { languageTag -> [String: Any?] in
97
- var locale = Locale.init(identifier: languageTag)
134
+ let languageLocale = Locale.init(identifier: languageTag)
135
+
98
136
  return [
99
137
  "languageTag": languageTag,
100
- "languageCode": locale.languageCode,
101
- "regionCode": locale.regionCode,
138
+ "languageCode": languageLocale.languageCode,
139
+ "regionCode": languageLocale.regionCode,
102
140
  "textDirection": Locale.characterDirection(forLanguage: languageTag) == .rightToLeft ? "rtl" : "ltr",
103
- "decimalSeparator": locale.decimalSeparator,
104
- "digitGroupingSeparator": locale.groupingSeparator,
105
- "measurementSystem": locale.usesMetricSystem ? "metric" : "us",
106
- "currencyCode": locale.currencyCode,
107
- "currencySymbol": locale.currencySymbol
141
+ "decimalSeparator": userSettingsLocale.decimalSeparator,
142
+ "digitGroupingSeparator": userSettingsLocale.groupingSeparator,
143
+ "measurementSystem": getMeasurementSystemForLocale(userSettingsLocale),
144
+ "currencyCode": languageLocale.currencyCode,
145
+ "currencySymbol": languageLocale.currencySymbol
108
146
  ]
109
147
  }
110
148
  }
111
149
 
150
+ @objc
151
+ private func localeChanged() {
152
+ // we send both events since on iOS it means both calendar and locale needs an update
153
+ sendEvent(LOCALE_SETTINGS_CHANGED)
154
+ sendEvent(CALENDAR_SETTINGS_CHANGED)
155
+ }
156
+
112
157
  // https://stackoverflow.com/a/28183182
113
158
  static func uses24HourClock() -> Bool {
114
159
  let dateFormat = DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: Locale.current)!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-localization",
3
- "version": "14.2.0",
3
+ "version": "14.4.0",
4
4
  "description": "Provides an interface for native user localization information.",
5
5
  "main": "build/Localization.js",
6
6
  "types": "build/Localization.d.ts",
@@ -47,5 +47,5 @@
47
47
  "peerDependencies": {
48
48
  "expo": "*"
49
49
  },
50
- "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
50
+ "gitHead": "2240630a92eb79a4e4bf73e1439916c394876478"
51
51
  }
@@ -1,3 +1,7 @@
1
- import { ConfigPlugin } from 'expo/config-plugins';
2
- declare const _default: ConfigPlugin<void>;
3
- export default _default;
1
+ import { ExpoConfig } from '@expo/config-types';
2
+ type ConfigPluginProps = {
3
+ supportsRTL?: boolean;
4
+ allowDynamicLocaleChangesAndroid?: boolean;
5
+ };
6
+ declare function withExpoLocalization(config: ExpoConfig, data?: ConfigPluginProps): ExpoConfig;
7
+ export default withExpoLocalization;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Manifest_1 = require("@expo/config-plugins/build/android/Manifest");
3
4
  const config_plugins_1 = require("expo/config-plugins");
4
- const pkg = require('expo-localization/package.json');
5
- const withExpoLocalization = (config) => {
5
+ function withExpoLocalizationIos(config) {
6
6
  if (config.extra?.supportsRTL == null)
7
7
  return config;
8
8
  if (!config.ios)
@@ -10,16 +10,37 @@ const withExpoLocalization = (config) => {
10
10
  if (!config.ios.infoPlist)
11
11
  config.ios.infoPlist = {};
12
12
  config.ios.infoPlist.ExpoLocalization_supportsRTL = config.extra?.supportsRTL || false;
13
+ return config;
14
+ }
15
+ function withExpoLocalizationAndroid(config, data) {
16
+ if (data.allowDynamicLocaleChangesAndroid) {
17
+ config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
18
+ const mainActivity = (0, Manifest_1.getMainActivityOrThrow)(config.modResults);
19
+ if (!mainActivity.$['android:configChanges']?.includes('locale')) {
20
+ mainActivity.$['android:configChanges'] += '|locale';
21
+ }
22
+ if (!mainActivity.$['android:configChanges']?.includes('layoutDirection')) {
23
+ mainActivity.$['android:configChanges'] += '|layoutDirection';
24
+ }
25
+ return config;
26
+ });
27
+ }
13
28
  return (0, config_plugins_1.withStringsXml)(config, (config) => {
14
29
  config.modResults = config_plugins_1.AndroidConfig.Strings.setStringItem([
15
- // XML represented as JSON
16
- // <string name="expo_custom_value" translatable="false">value</string>
17
30
  {
18
31
  $: { name: 'ExpoLocalization_supportsRTL', translatable: 'false' },
19
- _: String(config.extra?.supportsRTL),
32
+ _: String(data.supportsRTL ?? config.extra?.supportsRTL),
20
33
  },
21
34
  ], config.modResults);
22
35
  return config;
23
36
  });
24
- };
25
- exports.default = (0, config_plugins_1.createRunOncePlugin)(withExpoLocalization, pkg.name, pkg.version);
37
+ }
38
+ function withExpoLocalization(config, data = {
39
+ allowDynamicLocaleChangesAndroid: true,
40
+ }) {
41
+ return (0, config_plugins_1.withPlugins)(config, [
42
+ [withExpoLocalizationIos, data],
43
+ [withExpoLocalizationAndroid, data],
44
+ ]);
45
+ }
46
+ exports.default = withExpoLocalization;
@@ -1,32 +1,62 @@
1
+ import { getMainActivityOrThrow } from '@expo/config-plugins/build/android/Manifest';
2
+ import { ExpoConfig } from '@expo/config-types';
1
3
  import {
2
4
  AndroidConfig,
3
- ConfigPlugin,
4
- createRunOncePlugin,
5
+ withAndroidManifest,
6
+ withPlugins,
5
7
  withStringsXml,
6
8
  } from 'expo/config-plugins';
7
9
 
8
- const pkg = require('expo-localization/package.json');
10
+ type ConfigPluginProps = {
11
+ supportsRTL?: boolean;
12
+ allowDynamicLocaleChangesAndroid?: boolean;
13
+ };
9
14
 
10
- const withExpoLocalization: ConfigPlugin = (config) => {
15
+ function withExpoLocalizationIos(config: ExpoConfig) {
11
16
  if (config.extra?.supportsRTL == null) return config;
12
17
  if (!config.ios) config.ios = {};
13
18
  if (!config.ios.infoPlist) config.ios.infoPlist = {};
14
19
  config.ios.infoPlist.ExpoLocalization_supportsRTL = config.extra?.supportsRTL || false;
20
+ return config;
21
+ }
15
22
 
23
+ function withExpoLocalizationAndroid(config: ExpoConfig, data: ConfigPluginProps) {
24
+ if (data.allowDynamicLocaleChangesAndroid) {
25
+ config = withAndroidManifest(config, (config) => {
26
+ const mainActivity = getMainActivityOrThrow(config.modResults);
27
+ if (!mainActivity.$['android:configChanges']?.includes('locale')) {
28
+ mainActivity.$['android:configChanges'] += '|locale';
29
+ }
30
+ if (!mainActivity.$['android:configChanges']?.includes('layoutDirection')) {
31
+ mainActivity.$['android:configChanges'] += '|layoutDirection';
32
+ }
33
+ return config;
34
+ });
35
+ }
16
36
  return withStringsXml(config, (config) => {
17
37
  config.modResults = AndroidConfig.Strings.setStringItem(
18
38
  [
19
- // XML represented as JSON
20
- // <string name="expo_custom_value" translatable="false">value</string>
21
39
  {
22
40
  $: { name: 'ExpoLocalization_supportsRTL', translatable: 'false' },
23
- _: String(config.extra?.supportsRTL),
41
+ _: String(data.supportsRTL ?? config.extra?.supportsRTL),
24
42
  },
25
43
  ],
26
44
  config.modResults
27
45
  );
28
46
  return config;
29
47
  });
30
- };
48
+ }
49
+
50
+ function withExpoLocalization(
51
+ config: ExpoConfig,
52
+ data: ConfigPluginProps = {
53
+ allowDynamicLocaleChangesAndroid: true,
54
+ }
55
+ ) {
56
+ return withPlugins(config, [
57
+ [withExpoLocalizationIos, data],
58
+ [withExpoLocalizationAndroid, data],
59
+ ]);
60
+ }
31
61
 
32
- export default createRunOncePlugin(withExpoLocalization, pkg.name, pkg.version);
62
+ export default withExpoLocalization;
@@ -1,3 +1,18 @@
1
- import { requireNativeModule } from 'expo-modules-core';
1
+ import { EventEmitter, Subscription, requireNativeModule } from 'expo-modules-core';
2
2
 
3
- export default requireNativeModule('ExpoLocalization');
3
+ const ExpoLocalizationModule = requireNativeModule('ExpoLocalization');
4
+ const emitter = new EventEmitter(ExpoLocalizationModule);
5
+
6
+ export function addLocaleListener(listener: (event) => void): Subscription {
7
+ return emitter.addListener('onLocaleSettingsChanged', listener);
8
+ }
9
+
10
+ export function addCalendarListener(listener: (event) => void): Subscription {
11
+ return emitter.addListener('onCalendarSettingsChanged', listener);
12
+ }
13
+
14
+ export function removeSubscription(subscription: Subscription) {
15
+ return emitter.removeSubscription(subscription);
16
+ }
17
+
18
+ export default ExpoLocalizationModule;
@@ -1,5 +1,5 @@
1
1
  /* eslint-env browser */
2
- import { Platform } from 'expo-modules-core';
2
+ import { Platform, Subscription } from 'expo-modules-core';
3
3
  import * as rtlDetect from 'rtl-detect';
4
4
 
5
5
  import { Localization, Calendar, Locale, CalendarIdentifier } from './Localization.types';
@@ -19,6 +19,25 @@ type ExtendedLocale = Intl.Locale &
19
19
  calendars: string[];
20
20
  }>;
21
21
 
22
+ const WEB_LANGUAGE_CHANGE_EVENT = 'languagechange';
23
+
24
+ export function addLocaleListener(listener: (event) => void): Subscription {
25
+ addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);
26
+ return {
27
+ remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),
28
+ };
29
+ }
30
+
31
+ export function addCalendarListener(listener: (event) => void): Subscription {
32
+ addEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener);
33
+ return {
34
+ remove: () => removeEventListener(WEB_LANGUAGE_CHANGE_EVENT, listener),
35
+ };
36
+ }
37
+ export function removeSubscription(subscription: Subscription) {
38
+ subscription.remove();
39
+ }
40
+
22
41
  export default {
23
42
  get currency(): string | null {
24
43
  // TODO: Add support
@@ -130,6 +149,7 @@ export default {
130
149
  },
131
150
  ];
132
151
  },
152
+
133
153
  async getLocalizationAsync(): Promise<Omit<Localization, 'getCalendars' | 'getLocales'>> {
134
154
  const {
135
155
  currency,
@@ -1,4 +1,10 @@
1
- import ExpoLocalization from './ExpoLocalization';
1
+ import { useEffect, useReducer, useMemo } from 'react';
2
+
3
+ import ExpoLocalization, {
4
+ addCalendarListener,
5
+ addLocaleListener,
6
+ removeSubscription,
7
+ } from './ExpoLocalization';
2
8
  import { Localization } from './Localization.types';
3
9
  export * from './Localization.types';
4
10
 
@@ -131,6 +137,63 @@ export const getLocales = ExpoLocalization.getLocales;
131
137
  */
132
138
  export const getCalendars = ExpoLocalization.getCalendars;
133
139
 
140
+ /**
141
+ * A hook providing a list of user's locales, returned as an array of objects of type `Locale`.
142
+ * Guaranteed to contain at least 1 element.
143
+ * These are returned in the order the user defines in their device settings.
144
+ * On the web currency and measurements systems are not provided, instead returned as null.
145
+ * If needed, you can infer them from the current region using a lookup table.
146
+ * If the OS settings change, the hook will rerender with a new list of locales.
147
+ * @example `[{
148
+ "languageTag": "pl-PL",
149
+ "languageCode": "pl",
150
+ "textDirection": "ltr",
151
+ "digitGroupingSeparator": " ",
152
+ "decimalSeparator": ",",
153
+ "measurementSystem": "metric",
154
+ "currencyCode": "PLN",
155
+ "currencySymbol": "zł",
156
+ "regionCode": "PL"
157
+ }]`
158
+ */
159
+ export function useLocales() {
160
+ const [key, invalidate] = useReducer((k) => k + 1, 0);
161
+ const locales = useMemo(() => getLocales(), [key]);
162
+ useEffect(() => {
163
+ const subscription = addLocaleListener(invalidate);
164
+ return () => {
165
+ removeSubscription(subscription);
166
+ };
167
+ }, []);
168
+ return locales;
169
+ }
170
+
171
+ /**
172
+ * A hook providing a list of user's preferred calendars, returned as an array of objects of type `Calendar`.
173
+ * Guaranteed to contain at least 1 element.
174
+ * For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
175
+ * If the OS settings change, the hook will rerender with a new list of calendars.
176
+ * @example `[
177
+ {
178
+ "calendar": "gregory",
179
+ "timeZone": "Europe/Warsaw",
180
+ "uses24hourClock": true,
181
+ "firstWeekday": 1
182
+ }
183
+ ]`
184
+ */
185
+ export function useCalendars() {
186
+ const [key, invalidate] = useReducer((k) => k + 1, 0);
187
+ const calendars = useMemo(() => getCalendars(), [key]);
188
+ useEffect(() => {
189
+ const subscription = addCalendarListener(invalidate);
190
+ return () => {
191
+ removeSubscription(subscription);
192
+ };
193
+ }, []);
194
+ return calendars;
195
+ }
196
+
134
197
  // @needsAudit
135
198
  /**
136
199
  * Get the latest native values from the device. Locale can be changed on some Android devices
@@ -109,8 +109,6 @@ export type Locale = {
109
109
  textDirection: 'ltr' | 'rtl' | null;
110
110
  /**
111
111
  * The measurement system used in the locale.
112
- * On iOS is one of `'metric'`, `'us'`. On Android is one of `'metric'`, `'us'`, `'uk'`.
113
- *
114
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.
115
113
  * Ask for user preferences if possible.
116
114
  */
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "./build"
6
6
  },
7
7
  "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
9
  }