expo-localization 14.8.4 → 15.0.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 +10 -5
- package/android/build.gradle +7 -93
- package/android/src/main/java/expo/modules/localization/LocalizationModule.kt +18 -9
- package/build/ExpoLocalization.d.ts +1 -1
- package/build/ExpoLocalization.d.ts.map +1 -1
- package/build/ExpoLocalization.js +1 -1
- package/build/ExpoLocalization.js.map +1 -1
- package/build/Localization.d.ts +62 -47
- package/build/Localization.d.ts.map +1 -1
- package/build/Localization.js +62 -47
- package/build/Localization.js.map +1 -1
- package/build/Localization.types.d.ts +31 -23
- package/build/Localization.types.d.ts.map +1 -1
- package/build/Localization.types.js.map +1 -1
- package/package.json +2 -2
- package/src/Localization.ts +62 -47
- package/src/Localization.types.ts +31 -24
package/CHANGELOG.md
CHANGED
|
@@ -10,21 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 15.0.0 — 2024-04-18
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
16
|
|
|
17
17
|
- [iOS] Add privacy manifest describing required reason API usage. ([#27770](https://github.com/expo/expo/pull/27770) by [@aleqsio](https://github.com/aleqsio))
|
|
18
|
+
- [Android] Fix es-419 locale returning empty list. ([#27250](https://github.com/expo/expo/pull/27250) by [@aleqsio](https://github.com/aleqsio))
|
|
19
|
+
|
|
20
|
+
### 💡 Others
|
|
21
|
+
|
|
22
|
+
- Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
|
|
18
23
|
|
|
19
|
-
## 14.8.3
|
|
24
|
+
## 14.8.3 - 2024-01-18
|
|
20
25
|
|
|
21
26
|
_This version does not introduce any user-facing changes._
|
|
22
27
|
|
|
23
|
-
## 14.8.2
|
|
28
|
+
## 14.8.2 - 2024-01-10
|
|
24
29
|
|
|
25
30
|
_This version does not introduce any user-facing changes._
|
|
26
31
|
|
|
27
|
-
## 14.8.1
|
|
32
|
+
## 14.8.1 - 2023-12-19
|
|
28
33
|
|
|
29
34
|
_This version does not introduce any user-facing changes._
|
|
30
35
|
|
package/android/build.gradle
CHANGED
|
@@ -1,109 +1,23 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
|
-
apply plugin: 'kotlin-android'
|
|
3
|
-
apply plugin: 'maven-publish'
|
|
4
2
|
|
|
5
3
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
4
|
+
version = '15.0.0'
|
|
7
5
|
|
|
8
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
}
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useDefaultAndroidSdkVersions()
|
|
11
|
+
useExpoPublishing()
|
|
60
12
|
|
|
61
13
|
android {
|
|
62
|
-
// Remove this if and it's contents, when support for SDK49 is dropped
|
|
63
|
-
if (!safeExtGet("expoProvidesDefaultConfig", false)) {
|
|
64
|
-
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
65
|
-
|
|
66
|
-
defaultConfig {
|
|
67
|
-
minSdkVersion safeExtGet("minSdkVersion", 23)
|
|
68
|
-
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
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
14
|
namespace "expo.modules.localization"
|
|
95
15
|
defaultConfig {
|
|
96
16
|
versionCode 22
|
|
97
|
-
versionName "
|
|
17
|
+
versionName "15.0.0"
|
|
98
18
|
}
|
|
99
19
|
}
|
|
100
20
|
|
|
101
21
|
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
22
|
implementation "androidx.core:core-ktx:1.6.0"
|
|
109
23
|
}
|
|
@@ -19,8 +19,6 @@ import expo.modules.kotlin.modules.ModuleDefinition
|
|
|
19
19
|
import java.text.DecimalFormatSymbols
|
|
20
20
|
import java.util.*
|
|
21
21
|
|
|
22
|
-
// EXPO_VERSIONING_NEEDS_PACKAGE_R
|
|
23
|
-
|
|
24
22
|
// must be kept in sync with https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.java
|
|
25
23
|
private const val SHARED_PREFS_NAME = "com.facebook.react.modules.i18nmanager.I18nUtil"
|
|
26
24
|
private const val KEY_FOR_PREFS_ALLOWRTL = "RCTI18nUtil_allowRTL"
|
|
@@ -38,7 +36,7 @@ class LocalizationModule : Module() {
|
|
|
38
36
|
bundledConstants.toShallowMap()
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
AsyncFunction("getLocalizationAsync") {
|
|
39
|
+
AsyncFunction<Bundle>("getLocalizationAsync") {
|
|
42
40
|
return@AsyncFunction bundledConstants
|
|
43
41
|
}
|
|
44
42
|
|
|
@@ -53,7 +51,7 @@ class LocalizationModule : Module() {
|
|
|
53
51
|
Events(LOCALE_SETTINGS_CHANGED, CALENDAR_SETTINGS_CHANGED)
|
|
54
52
|
|
|
55
53
|
OnCreate {
|
|
56
|
-
appContext
|
|
54
|
+
appContext.reactContext?.let {
|
|
57
55
|
setRTLFromStringResources(it)
|
|
58
56
|
}
|
|
59
57
|
observer = {
|
|
@@ -139,6 +137,21 @@ class LocalizationModule : Module() {
|
|
|
139
137
|
}
|
|
140
138
|
}
|
|
141
139
|
|
|
140
|
+
private fun getCurrencyProperties(locale: Locale): Map<String, Any?> {
|
|
141
|
+
return try {
|
|
142
|
+
mapOf(
|
|
143
|
+
"currencyCode" to Currency.getInstance(locale).currencyCode,
|
|
144
|
+
// currency symbol can be localized to display locale (1st on the list) or to the locale for the currency (as done here).
|
|
145
|
+
"currencySymbol" to Currency.getInstance(locale).getSymbol(locale)
|
|
146
|
+
)
|
|
147
|
+
} catch (e: Exception) {
|
|
148
|
+
mapOf(
|
|
149
|
+
"currencyCode" to null,
|
|
150
|
+
"currencySymbol" to null
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
142
155
|
private fun getPreferredLocales(): List<Map<String, Any?>> {
|
|
143
156
|
val locales = mutableListOf<Map<String, Any?>>()
|
|
144
157
|
val localeList: LocaleListCompat = LocaleListCompat.getDefault()
|
|
@@ -158,12 +171,8 @@ class LocalizationModule : Module() {
|
|
|
158
171
|
"digitGroupingSeparator" to decimalFormat.groupingSeparator.toString(),
|
|
159
172
|
|
|
160
173
|
"measurementSystem" to getMeasurementSystem(locale),
|
|
161
|
-
"currencyCode" to decimalFormat.currency.currencyCode,
|
|
162
|
-
|
|
163
|
-
// currency symbol can be localized to display locale (1st on the list) or to the locale for the currency (as done here).
|
|
164
|
-
"currencySymbol" to Currency.getInstance(locale).getSymbol(locale),
|
|
165
174
|
"temperatureUnit" to getTemperatureUnit(locale)
|
|
166
|
-
)
|
|
175
|
+
) + getCurrencyProperties(locale)
|
|
167
176
|
)
|
|
168
177
|
} catch (e: Exception) {
|
|
169
178
|
// warn about the problematic locale
|
|
@@ -16,7 +16,7 @@ declare const _default: {
|
|
|
16
16
|
readonly region: string | null;
|
|
17
17
|
getLocales(): Locale[];
|
|
18
18
|
getCalendars(): Calendar[];
|
|
19
|
-
getLocalizationAsync(): Promise<Omit<Localization,
|
|
19
|
+
getLocalizationAsync(): Promise<Omit<Localization, "getCalendars" | "getLocales">>;
|
|
20
20
|
};
|
|
21
21
|
export default _default;
|
|
22
22
|
//# sourceMappingURL=ExpoLocalization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;AAoC1F,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;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,QAE5D;;;;;;;;;;;;kBAsEe,MAAM,EAAE;oBAgCN,QAAQ,EAAE;4BAcI,
|
|
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;AAoC1F,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;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,QAE5D;;;;;;;;;;;;kBAsEe,MAAM,EAAE;oBAgCN,QAAQ,EAAE;4BAcI,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC;;AAlH1F,wBA4IE"}
|
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
{
|
|
140
140
|
calendar: (locale?.calendar || locale?.calendars?.[0]) || null,
|
|
141
141
|
timeZone: locale?.timeZone || locale?.timeZones?.[0] || null,
|
|
142
|
-
uses24hourClock: (locale?.hourCycle || locale?.hourCycles?.[0])?.startsWith('h2') ?? null,
|
|
142
|
+
uses24hourClock: (locale?.hourCycle || locale?.hourCycles?.[0])?.startsWith('h2') ?? null, //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle
|
|
143
143
|
firstWeekday: locale?.weekInfo?.firstDay || null,
|
|
144
144
|
},
|
|
145
145
|
];
|
|
@@ -1 +1 @@
|
|
|
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,EAAE;IAC/B,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC,CAAC;AAaF,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AACnD,wEAAwE;AACxE,MAAM,eAAe,GAAG;IACtB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IA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C;IACJ,CAAC;CACF,CAAC;AAEF,SAAS,uBAAuB,CAAC,MAAc;IAC7C,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,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// https://wisevoter.com/country-rankings/countries-that-use-fahrenheit/\nconst USES_FAHRENHEIT = [\n 'AG',\n 'BZ',\n 'VG',\n 'FM',\n 'MH',\n 'MS',\n 'KN',\n 'BS',\n 'CY',\n 'TC',\n 'US',\n 'LR',\n 'PW',\n 'KY',\n];\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}\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 const temperatureUnit = region ? regionToTemperatureUnit(region) : null;\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 temperatureUnit,\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\nfunction regionToTemperatureUnit(region: string) {\n return USES_FAHRENHEIT.includes(region) ? 'fahrenheit' : 'celsius';\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,EAAE;IAC/B,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,SAAS,C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IACJ,CAAC;IAED,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;AAEF,SAAS,uBAAuB,CAAC,MAAc;IAC7C,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,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// https://wisevoter.com/country-rankings/countries-that-use-fahrenheit/\nconst USES_FAHRENHEIT = [\n 'AG',\n 'BZ',\n 'VG',\n 'FM',\n 'MH',\n 'MS',\n 'KN',\n 'BS',\n 'CY',\n 'TC',\n 'US',\n 'LR',\n 'PW',\n 'KY',\n];\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}\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 const temperatureUnit = region ? regionToTemperatureUnit(region) : null;\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 temperatureUnit,\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\nfunction regionToTemperatureUnit(region: string) {\n return USES_FAHRENHEIT.includes(region) ? 'fahrenheit' : 'celsius';\n}\n"]}
|
package/build/Localization.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export * from './Localization.types';
|
|
|
5
5
|
* @deprecated Use Localization.getLocales() instead.
|
|
6
6
|
* Three-character ISO 4217 currency code. Returns `null` on web.
|
|
7
7
|
*
|
|
8
|
-
* @example
|
|
8
|
+
* @example
|
|
9
|
+
* `'USD'`, `'EUR'`, `'CNY'`, `null`
|
|
9
10
|
*/
|
|
10
11
|
export declare const currency: string | null;
|
|
11
12
|
/**
|
|
@@ -13,7 +14,8 @@ export declare const currency: string | null;
|
|
|
13
14
|
* @deprecated Use Localization.getLocales() instead.
|
|
14
15
|
* Decimal separator used for formatting numbers.
|
|
15
16
|
*
|
|
16
|
-
* @example
|
|
17
|
+
* @example
|
|
18
|
+
* `','`, `'.'`
|
|
17
19
|
*/
|
|
18
20
|
export declare const decimalSeparator: string;
|
|
19
21
|
/**
|
|
@@ -21,7 +23,8 @@ export declare const decimalSeparator: string;
|
|
|
21
23
|
* @deprecated Use Localization.getLocales() instead.
|
|
22
24
|
* Digit grouping separator used when formatting numbers larger than 1000.
|
|
23
25
|
*
|
|
24
|
-
* @example
|
|
26
|
+
* @example
|
|
27
|
+
* `'.'`, `''`, `','`
|
|
25
28
|
*/
|
|
26
29
|
export declare const digitGroupingSeparator: string;
|
|
27
30
|
/**
|
|
@@ -51,7 +54,8 @@ export declare const isRTL: boolean;
|
|
|
51
54
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
|
52
55
|
* consisting of a two-character language code and optional script, region and variant codes.
|
|
53
56
|
*
|
|
54
|
-
* @example
|
|
57
|
+
* @example
|
|
58
|
+
* `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
|
55
59
|
*/
|
|
56
60
|
export declare const locale: string;
|
|
57
61
|
/**
|
|
@@ -60,7 +64,8 @@ export declare const locale: string;
|
|
|
60
64
|
* List of all the native languages provided by the user settings.
|
|
61
65
|
* These are returned in the order the user defines in their device settings.
|
|
62
66
|
*
|
|
63
|
-
* @example
|
|
67
|
+
* @example
|
|
68
|
+
* `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
|
64
69
|
*/
|
|
65
70
|
export declare const locales: string[];
|
|
66
71
|
/**
|
|
@@ -71,7 +76,8 @@ export declare const locales: string[];
|
|
|
71
76
|
* better estimation you could use the moment-timezone package but it will add significant bloat to
|
|
72
77
|
* your website's bundle size.
|
|
73
78
|
*
|
|
74
|
-
* @example
|
|
79
|
+
* @example
|
|
80
|
+
* `'America/Los_Angeles'`
|
|
75
81
|
*/
|
|
76
82
|
export declare const timezone: string;
|
|
77
83
|
/**
|
|
@@ -80,7 +86,8 @@ export declare const timezone: string;
|
|
|
80
86
|
* The region code for your device that comes from the Region setting under Language & Region on iOS.
|
|
81
87
|
* This value is always available on iOS, but might return `null` on Android or web.
|
|
82
88
|
*
|
|
83
|
-
* @example
|
|
89
|
+
* @example
|
|
90
|
+
* `'US'`, `'NZ'`, `null`
|
|
84
91
|
*/
|
|
85
92
|
export declare const region: string | null;
|
|
86
93
|
/**
|
|
@@ -89,32 +96,36 @@ export declare const region: string | null;
|
|
|
89
96
|
* These are returned in the order the user defines in their device settings.
|
|
90
97
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
91
98
|
* If needed, you can infer them from the current region using a lookup table.
|
|
92
|
-
* @example
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
* @example
|
|
100
|
+
* ```js
|
|
101
|
+
* [{
|
|
102
|
+
* "languageTag": "pl-PL",
|
|
103
|
+
* "languageCode": "pl",
|
|
104
|
+
* "textDirection": "ltr",
|
|
105
|
+
* "digitGroupingSeparator": " ",
|
|
106
|
+
* "decimalSeparator": ",",
|
|
107
|
+
* "measurementSystem": "metric",
|
|
108
|
+
* "currencyCode": "PLN",
|
|
109
|
+
* "currencySymbol": "zł",
|
|
110
|
+
* "regionCode": "PL",
|
|
111
|
+
* "temperatureUnit": "celsius"
|
|
112
|
+
* }]
|
|
113
|
+
* ```
|
|
104
114
|
*/
|
|
105
115
|
export declare const getLocales: () => import("./Localization.types").Locale[];
|
|
106
116
|
/**
|
|
107
117
|
* List of user's preferred calendars, returned as an array of objects of type `Calendar`.
|
|
108
118
|
* Guaranteed to contain at least 1 element.
|
|
109
119
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
110
|
-
* @example
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
* @example
|
|
121
|
+
* ```js
|
|
122
|
+
* [{
|
|
123
|
+
* "calendar": "gregory",
|
|
124
|
+
* "timeZone": "Europe/Warsaw",
|
|
125
|
+
* "uses24hourClock": true,
|
|
126
|
+
* "firstWeekday": 1
|
|
127
|
+
* }]
|
|
128
|
+
* ```
|
|
118
129
|
*/
|
|
119
130
|
export declare const getCalendars: () => import("./Localization.types").Calendar[];
|
|
120
131
|
/**
|
|
@@ -124,18 +135,21 @@ export declare const getCalendars: () => import("./Localization.types").Calendar
|
|
|
124
135
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
125
136
|
* If needed, you can infer them from the current region using a lookup table.
|
|
126
137
|
* If the OS settings change, the hook will rerender with a new list of locales.
|
|
127
|
-
* @example
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
* @example
|
|
139
|
+
* ```js
|
|
140
|
+
* [{
|
|
141
|
+
* "languageTag": "pl-PL",
|
|
142
|
+
* "languageCode": "pl",
|
|
143
|
+
* "textDirection": "ltr",
|
|
144
|
+
* "digitGroupingSeparator": " ",
|
|
145
|
+
* "decimalSeparator": ",",
|
|
146
|
+
* "measurementSystem": "metric",
|
|
147
|
+
* "currencyCode": "PLN",
|
|
148
|
+
* "currencySymbol": "zł",
|
|
149
|
+
* "regionCode": "PL",
|
|
150
|
+
* "temperatureUnit": "celsius"
|
|
151
|
+
* }]
|
|
152
|
+
* ```
|
|
139
153
|
*/
|
|
140
154
|
export declare function useLocales(): import("./Localization.types").Locale[];
|
|
141
155
|
/**
|
|
@@ -143,14 +157,15 @@ export declare function useLocales(): import("./Localization.types").Locale[];
|
|
|
143
157
|
* Guaranteed to contain at least 1 element.
|
|
144
158
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
145
159
|
* If the OS settings change, the hook will rerender with a new list of calendars.
|
|
146
|
-
* @example
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
* @example
|
|
161
|
+
* ```js
|
|
162
|
+
* [{
|
|
163
|
+
* "calendar": "gregory",
|
|
164
|
+
* "timeZone": "Europe/Warsaw",
|
|
165
|
+
* "uses24hourClock": true,
|
|
166
|
+
* "firstWeekday": 1
|
|
167
|
+
* }]
|
|
168
|
+
* ```
|
|
154
169
|
*/
|
|
155
170
|
export declare function useCalendars(): import("./Localization.types").Calendar[];
|
|
156
171
|
/**
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,eAA4B,CAAC;AAGlD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAoC,CAAC;AAGlE;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,QAA0C,CAAC;AAG9E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,UAAoC,CAAC;AAGlE;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,SAA4B,CAAC;AAGlD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,SAAyB,CAAC;AAG5C;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,QAA0B,CAAC;AAG9C;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,UAA2B,CAAC;AAGhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAGlD;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,eAA0B,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,UAAU,+CAA8B,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,iDAAgC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,4CAUzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,8CAU3B;AAGD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,CAElE"}
|
package/build/Localization.js
CHANGED
|
@@ -7,7 +7,8 @@ export * from './Localization.types';
|
|
|
7
7
|
* @deprecated Use Localization.getLocales() instead.
|
|
8
8
|
* Three-character ISO 4217 currency code. Returns `null` on web.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
10
|
+
* @example
|
|
11
|
+
* `'USD'`, `'EUR'`, `'CNY'`, `null`
|
|
11
12
|
*/
|
|
12
13
|
export const currency = ExpoLocalization.currency;
|
|
13
14
|
// @needsAudit
|
|
@@ -16,7 +17,8 @@ export const currency = ExpoLocalization.currency;
|
|
|
16
17
|
* @deprecated Use Localization.getLocales() instead.
|
|
17
18
|
* Decimal separator used for formatting numbers.
|
|
18
19
|
*
|
|
19
|
-
* @example
|
|
20
|
+
* @example
|
|
21
|
+
* `','`, `'.'`
|
|
20
22
|
*/
|
|
21
23
|
export const decimalSeparator = ExpoLocalization.decimalSeparator;
|
|
22
24
|
// @needsAudit
|
|
@@ -25,7 +27,8 @@ export const decimalSeparator = ExpoLocalization.decimalSeparator;
|
|
|
25
27
|
* @deprecated Use Localization.getLocales() instead.
|
|
26
28
|
* Digit grouping separator used when formatting numbers larger than 1000.
|
|
27
29
|
*
|
|
28
|
-
* @example
|
|
30
|
+
* @example
|
|
31
|
+
* `'.'`, `''`, `','`
|
|
29
32
|
*/
|
|
30
33
|
export const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;
|
|
31
34
|
// @needsAudit
|
|
@@ -59,7 +62,8 @@ export const isRTL = ExpoLocalization.isRTL;
|
|
|
59
62
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
|
60
63
|
* consisting of a two-character language code and optional script, region and variant codes.
|
|
61
64
|
*
|
|
62
|
-
* @example
|
|
65
|
+
* @example
|
|
66
|
+
* `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
|
63
67
|
*/
|
|
64
68
|
export const locale = ExpoLocalization.locale;
|
|
65
69
|
// @needsAudit
|
|
@@ -69,7 +73,8 @@ export const locale = ExpoLocalization.locale;
|
|
|
69
73
|
* List of all the native languages provided by the user settings.
|
|
70
74
|
* These are returned in the order the user defines in their device settings.
|
|
71
75
|
*
|
|
72
|
-
* @example
|
|
76
|
+
* @example
|
|
77
|
+
* `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
|
73
78
|
*/
|
|
74
79
|
export const locales = ExpoLocalization.locales;
|
|
75
80
|
// @needsAudit
|
|
@@ -81,7 +86,8 @@ export const locales = ExpoLocalization.locales;
|
|
|
81
86
|
* better estimation you could use the moment-timezone package but it will add significant bloat to
|
|
82
87
|
* your website's bundle size.
|
|
83
88
|
*
|
|
84
|
-
* @example
|
|
89
|
+
* @example
|
|
90
|
+
* `'America/Los_Angeles'`
|
|
85
91
|
*/
|
|
86
92
|
export const timezone = ExpoLocalization.timezone;
|
|
87
93
|
// @needsAudit
|
|
@@ -91,7 +97,8 @@ export const timezone = ExpoLocalization.timezone;
|
|
|
91
97
|
* The region code for your device that comes from the Region setting under Language & Region on iOS.
|
|
92
98
|
* This value is always available on iOS, but might return `null` on Android or web.
|
|
93
99
|
*
|
|
94
|
-
* @example
|
|
100
|
+
* @example
|
|
101
|
+
* `'US'`, `'NZ'`, `null`
|
|
95
102
|
*/
|
|
96
103
|
export const region = ExpoLocalization.region;
|
|
97
104
|
/**
|
|
@@ -100,32 +107,36 @@ export const region = ExpoLocalization.region;
|
|
|
100
107
|
* These are returned in the order the user defines in their device settings.
|
|
101
108
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
102
109
|
* If needed, you can infer them from the current region using a lookup table.
|
|
103
|
-
* @example
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
* @example
|
|
111
|
+
* ```js
|
|
112
|
+
* [{
|
|
113
|
+
* "languageTag": "pl-PL",
|
|
114
|
+
* "languageCode": "pl",
|
|
115
|
+
* "textDirection": "ltr",
|
|
116
|
+
* "digitGroupingSeparator": " ",
|
|
117
|
+
* "decimalSeparator": ",",
|
|
118
|
+
* "measurementSystem": "metric",
|
|
119
|
+
* "currencyCode": "PLN",
|
|
120
|
+
* "currencySymbol": "zł",
|
|
121
|
+
* "regionCode": "PL",
|
|
122
|
+
* "temperatureUnit": "celsius"
|
|
123
|
+
* }]
|
|
124
|
+
* ```
|
|
115
125
|
*/
|
|
116
126
|
export const getLocales = ExpoLocalization.getLocales;
|
|
117
127
|
/**
|
|
118
128
|
* List of user's preferred calendars, returned as an array of objects of type `Calendar`.
|
|
119
129
|
* Guaranteed to contain at least 1 element.
|
|
120
130
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
121
|
-
* @example
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
* @example
|
|
132
|
+
* ```js
|
|
133
|
+
* [{
|
|
134
|
+
* "calendar": "gregory",
|
|
135
|
+
* "timeZone": "Europe/Warsaw",
|
|
136
|
+
* "uses24hourClock": true,
|
|
137
|
+
* "firstWeekday": 1
|
|
138
|
+
* }]
|
|
139
|
+
* ```
|
|
129
140
|
*/
|
|
130
141
|
export const getCalendars = ExpoLocalization.getCalendars;
|
|
131
142
|
/**
|
|
@@ -135,18 +146,21 @@ export const getCalendars = ExpoLocalization.getCalendars;
|
|
|
135
146
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
136
147
|
* If needed, you can infer them from the current region using a lookup table.
|
|
137
148
|
* If the OS settings change, the hook will rerender with a new list of locales.
|
|
138
|
-
* @example
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
* @example
|
|
150
|
+
* ```js
|
|
151
|
+
* [{
|
|
152
|
+
* "languageTag": "pl-PL",
|
|
153
|
+
* "languageCode": "pl",
|
|
154
|
+
* "textDirection": "ltr",
|
|
155
|
+
* "digitGroupingSeparator": " ",
|
|
156
|
+
* "decimalSeparator": ",",
|
|
157
|
+
* "measurementSystem": "metric",
|
|
158
|
+
* "currencyCode": "PLN",
|
|
159
|
+
* "currencySymbol": "zł",
|
|
160
|
+
* "regionCode": "PL",
|
|
161
|
+
* "temperatureUnit": "celsius"
|
|
162
|
+
* }]
|
|
163
|
+
* ```
|
|
150
164
|
*/
|
|
151
165
|
export function useLocales() {
|
|
152
166
|
const [key, invalidate] = useReducer((k) => k + 1, 0);
|
|
@@ -164,14 +178,15 @@ export function useLocales() {
|
|
|
164
178
|
* Guaranteed to contain at least 1 element.
|
|
165
179
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
166
180
|
* If the OS settings change, the hook will rerender with a new list of calendars.
|
|
167
|
-
* @example
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
* @example
|
|
182
|
+
* ```js
|
|
183
|
+
* [{
|
|
184
|
+
* "calendar": "gregory",
|
|
185
|
+
* "timeZone": "Europe/Warsaw",
|
|
186
|
+
* "uses24hourClock": true,
|
|
187
|
+
* "firstWeekday": 1
|
|
188
|
+
* }]
|
|
189
|
+
* ```
|
|
175
190
|
*/
|
|
176
191
|
export function useCalendars() {
|
|
177
192
|
const [key, invalidate] = useReducer((k) => k + 1, 0);
|
|
@@ -1 +1 @@
|
|
|
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;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAElD,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;AAElE,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC;AAE9E,cAAc;AACd;;;;GAIG;AAC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AAC,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,EAAE,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;;;;;;;;;;;;;;;GAeG;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 * @hidden\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 * @hidden\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 * @hidden\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 * @hidden\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 * @hidden\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 * @hidden\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 * @deprecated Use [`Localization.getLocales()`](#localizationgetlocales) 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 * @hidden\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 * @hidden\n * @deprecated Use Localization.getCalendars() 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 * @hidden\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 \"temperatureUnit\": \"celsius\"\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 \"temperatureUnit\": \"celsius\"\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 * @hidden\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;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CA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C;IACtD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACnD,OAAO,GAAG,EAAE;YACV,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,EAAE,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;;;;;;;;;;;;;;;GAeG;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 * @hidden\n * @deprecated Use Localization.getLocales() instead.\n * Three-character ISO 4217 currency code. Returns `null` on web.\n *\n * @example\n * `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\nexport const currency = ExpoLocalization.currency;\n\n// @needsAudit\n/**\n * @hidden\n * @deprecated Use Localization.getLocales() instead.\n * Decimal separator used for formatting numbers.\n *\n * @example\n * `','`, `'.'`\n */\nexport const decimalSeparator = ExpoLocalization.decimalSeparator;\n\n// @needsAudit\n/**\n * @hidden\n * @deprecated Use Localization.getLocales() instead.\n * Digit grouping separator used when formatting numbers larger than 1000.\n *\n * @example\n * `'.'`, `''`, `','`\n */\nexport const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;\n\n// @needsAudit\n/**\n * @hidden\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 * @hidden\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 * @hidden\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 * @deprecated Use [`Localization.getLocales()`](#localizationgetlocales) 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\n * `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`\n */\nexport const locale = ExpoLocalization.locale;\n\n// @needsAudit\n/**\n * @hidden\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\n * `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`\n */\nexport const locales = ExpoLocalization.locales;\n\n// @needsAudit\n/**\n * @hidden\n * @deprecated Use Localization.getCalendars() 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\n * `'America/Los_Angeles'`\n */\nexport const timezone = ExpoLocalization.timezone;\n\n// @needsAudit\n/**\n * @hidden\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\n * `'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 * ```js\n * [{\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 * \"temperatureUnit\": \"celsius\"\n * }]\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 * ```js\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 * ```js\n * [{\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 * \"temperatureUnit\": \"celsius\"\n * }]\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 * ```js\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 * @hidden\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,20 +1,20 @@
|
|
|
1
1
|
export type Localization = {
|
|
2
2
|
/**
|
|
3
3
|
* Three-character ISO 4217 currency code. Returns `null` on web.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @example
|
|
5
|
+
* `'USD'`, `'EUR'`, `'CNY'`, `null`
|
|
6
6
|
*/
|
|
7
7
|
currency: string | null;
|
|
8
8
|
/**
|
|
9
9
|
* Decimal separator used for formatting numbers.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* @example
|
|
11
|
+
* `','`, `'.'`
|
|
12
12
|
*/
|
|
13
13
|
decimalSeparator: string;
|
|
14
14
|
/**
|
|
15
15
|
* Digit grouping separator used when formatting numbers larger than 1000.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* @example
|
|
17
|
+
* `'.'`, `''`, `','`
|
|
18
18
|
*/
|
|
19
19
|
digitGroupingSeparator: string;
|
|
20
20
|
/**
|
|
@@ -36,22 +36,22 @@ export type Localization = {
|
|
|
36
36
|
/**
|
|
37
37
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
|
38
38
|
* consisting of a two-character language code and optional script, region and variant codes.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* @example
|
|
40
|
+
* `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
|
41
41
|
*/
|
|
42
42
|
locale: string;
|
|
43
43
|
/**
|
|
44
44
|
* List of all the native languages provided by the user settings.
|
|
45
45
|
* These are returned in the order that the user defined in the device settings.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* @example
|
|
47
|
+
* `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
|
48
48
|
*/
|
|
49
49
|
locales: string[];
|
|
50
50
|
/**
|
|
51
51
|
* The region code for your device that comes from the Region setting under Language & Region on iOS.
|
|
52
52
|
* This value is always available on iOS, but might return `null` on Android or web.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* @example
|
|
54
|
+
* `'US'`, `'NZ'`, `null`
|
|
55
55
|
*/
|
|
56
56
|
region: string | null;
|
|
57
57
|
/**
|
|
@@ -59,20 +59,22 @@ export type Localization = {
|
|
|
59
59
|
* On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a
|
|
60
60
|
* better estimation you could use the moment-timezone package but it will add significant bloat to
|
|
61
61
|
* your website's bundle size.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
62
|
+
* @example
|
|
63
|
+
* `'America/Los_Angeles'`
|
|
64
64
|
*/
|
|
65
65
|
timezone: string;
|
|
66
66
|
};
|
|
67
67
|
export type Locale = {
|
|
68
68
|
/**
|
|
69
69
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
|
|
70
|
-
* @example
|
|
70
|
+
* @example
|
|
71
|
+
* `'en-US'`, `'es-419'`, `'pl-PL'`.
|
|
71
72
|
*/
|
|
72
73
|
languageTag: string;
|
|
73
74
|
/**
|
|
74
75
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.
|
|
75
|
-
* @example
|
|
76
|
+
* @example
|
|
77
|
+
* `'en'`, `'es'`, `'pl'`.
|
|
76
78
|
*/
|
|
77
79
|
languageCode: string | null;
|
|
78
80
|
/**
|
|
@@ -82,23 +84,27 @@ export type Locale = {
|
|
|
82
84
|
/**
|
|
83
85
|
* Currency code for the locale.
|
|
84
86
|
* Is `null` on Web, use a table lookup based on region instead.
|
|
85
|
-
* @example
|
|
87
|
+
* @example
|
|
88
|
+
* `'USD'`, `'EUR'`, `'PLN'`.
|
|
86
89
|
*/
|
|
87
90
|
currencyCode: string | null;
|
|
88
91
|
/**
|
|
89
92
|
* Currency symbol for the locale.
|
|
90
93
|
* Is `null` on Web, use a table lookup based on region (if available) instead.
|
|
91
|
-
* @example
|
|
94
|
+
* @example
|
|
95
|
+
* `'$'`, `'€'`, `'zł'`.
|
|
92
96
|
*/
|
|
93
97
|
currencySymbol: string | null;
|
|
94
98
|
/**
|
|
95
99
|
* Decimal separator used for formatting numbers with fractional parts.
|
|
96
|
-
* @example
|
|
100
|
+
* @example
|
|
101
|
+
* `'.'`, `','`.
|
|
97
102
|
*/
|
|
98
103
|
decimalSeparator: string | null;
|
|
99
104
|
/**
|
|
100
105
|
* Digit grouping separator used for formatting large numbers.
|
|
101
|
-
* @example
|
|
106
|
+
* @example
|
|
107
|
+
* `'.'`, `','`.
|
|
102
108
|
*/
|
|
103
109
|
digitGroupingSeparator: string | null;
|
|
104
110
|
/**
|
|
@@ -183,19 +189,21 @@ export type Calendar = {
|
|
|
183
189
|
*/
|
|
184
190
|
calendar: CalendarIdentifier | null;
|
|
185
191
|
/**
|
|
186
|
-
* True when current device settings use 24
|
|
192
|
+
* True when current device settings use 24-hour time format.
|
|
187
193
|
* Can be null on some browsers that don't support the [hourCycle](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
188
194
|
*/
|
|
189
195
|
uses24hourClock: boolean | null;
|
|
190
196
|
/**
|
|
191
197
|
* The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.
|
|
192
198
|
* Can be null on some browsers that don't support the [weekInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/weekInfo) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
193
|
-
* @example
|
|
199
|
+
* @example
|
|
200
|
+
* `1`, `7`.
|
|
194
201
|
*/
|
|
195
202
|
firstWeekday: Weekday | null;
|
|
196
203
|
/**
|
|
197
204
|
* Time zone for the calendar. Can be `null` on Web.
|
|
198
|
-
* @example
|
|
205
|
+
* @example
|
|
206
|
+
* `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.
|
|
199
207
|
*/
|
|
200
208
|
timeZone: string | null;
|
|
201
209
|
};
|
|
@@ -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,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB
|
|
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,E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AS,YAAY;IACrB,kCAAkC;IAClC,MAAM,WAAW;IACjB,sBAAsB;IACtB,MAAM,WAAW;IACjB,uBAAuB;IACvB,OAAO,YAAY;IACnB,kGAAkG;IAClG,aAAa,kBAAkB;IAC/B,8CAA8C;IAC9C,YAAY,iBAAiB;IAC7B,wGAAwG;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;;;;;OAKG;IACH,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B;;;;OAIG;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":"
|
|
1
|
+
{"version":3,"file":"Localization.types.js","sourceRoot":"","sources":["../src/Localization.types.ts"],"names":[],"mappings":"AAgIA;;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 * @example\n * `'USD'`, `'EUR'`, `'CNY'`, `null`\n */\n currency: string | null;\n /**\n * Decimal separator used for formatting numbers.\n * @example\n * `','`, `'.'`\n */\n decimalSeparator: string;\n /**\n * Digit grouping separator used when formatting numbers larger than 1000.\n * @example\n * `'.'`, `''`, `','`\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 * @example\n * `'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 * @example\n * `['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 * @example\n * `'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 * @example\n * `'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\n * `'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\n * `'en'`, `'es'`, `'pl'`.\n */\n languageCode: string | null;\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\n * `'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\n * `'$'`, `'€'`, `'zł'`.\n */\n currencySymbol: string | null;\n /**\n * Decimal separator used for formatting numbers with fractional parts.\n * @example\n * `'.'`, `','`.\n */\n decimalSeparator: string | null;\n /**\n * Digit grouping separator used for formatting large numbers.\n * @example\n * `'.'`, `','`.\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 * The temperature unit used in the locale.\n * Returns `null` if the region code is unknown.\n */\n temperatureUnit: 'celsius' | 'fahrenheit' | 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\n * `1`, `7`.\n */\n firstWeekday: Weekday | null;\n /**\n * Time zone for the calendar. Can be `null` on Web.\n * @example\n * `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.\n */\n timeZone: string | null;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-localization",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.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": "
|
|
50
|
+
"gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
|
|
51
51
|
}
|
package/src/Localization.ts
CHANGED
|
@@ -14,7 +14,8 @@ export * from './Localization.types';
|
|
|
14
14
|
* @deprecated Use Localization.getLocales() instead.
|
|
15
15
|
* Three-character ISO 4217 currency code. Returns `null` on web.
|
|
16
16
|
*
|
|
17
|
-
* @example
|
|
17
|
+
* @example
|
|
18
|
+
* `'USD'`, `'EUR'`, `'CNY'`, `null`
|
|
18
19
|
*/
|
|
19
20
|
export const currency = ExpoLocalization.currency;
|
|
20
21
|
|
|
@@ -24,7 +25,8 @@ export const currency = ExpoLocalization.currency;
|
|
|
24
25
|
* @deprecated Use Localization.getLocales() instead.
|
|
25
26
|
* Decimal separator used for formatting numbers.
|
|
26
27
|
*
|
|
27
|
-
* @example
|
|
28
|
+
* @example
|
|
29
|
+
* `','`, `'.'`
|
|
28
30
|
*/
|
|
29
31
|
export const decimalSeparator = ExpoLocalization.decimalSeparator;
|
|
30
32
|
|
|
@@ -34,7 +36,8 @@ export const decimalSeparator = ExpoLocalization.decimalSeparator;
|
|
|
34
36
|
* @deprecated Use Localization.getLocales() instead.
|
|
35
37
|
* Digit grouping separator used when formatting numbers larger than 1000.
|
|
36
38
|
*
|
|
37
|
-
* @example
|
|
39
|
+
* @example
|
|
40
|
+
* `'.'`, `''`, `','`
|
|
38
41
|
*/
|
|
39
42
|
export const digitGroupingSeparator = ExpoLocalization.digitGroupingSeparator;
|
|
40
43
|
|
|
@@ -72,7 +75,8 @@ export const isRTL = ExpoLocalization.isRTL;
|
|
|
72
75
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
|
73
76
|
* consisting of a two-character language code and optional script, region and variant codes.
|
|
74
77
|
*
|
|
75
|
-
* @example
|
|
78
|
+
* @example
|
|
79
|
+
* `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
|
76
80
|
*/
|
|
77
81
|
export const locale = ExpoLocalization.locale;
|
|
78
82
|
|
|
@@ -83,7 +87,8 @@ export const locale = ExpoLocalization.locale;
|
|
|
83
87
|
* List of all the native languages provided by the user settings.
|
|
84
88
|
* These are returned in the order the user defines in their device settings.
|
|
85
89
|
*
|
|
86
|
-
* @example
|
|
90
|
+
* @example
|
|
91
|
+
* `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
|
87
92
|
*/
|
|
88
93
|
export const locales = ExpoLocalization.locales;
|
|
89
94
|
|
|
@@ -96,7 +101,8 @@ export const locales = ExpoLocalization.locales;
|
|
|
96
101
|
* better estimation you could use the moment-timezone package but it will add significant bloat to
|
|
97
102
|
* your website's bundle size.
|
|
98
103
|
*
|
|
99
|
-
* @example
|
|
104
|
+
* @example
|
|
105
|
+
* `'America/Los_Angeles'`
|
|
100
106
|
*/
|
|
101
107
|
export const timezone = ExpoLocalization.timezone;
|
|
102
108
|
|
|
@@ -107,7 +113,8 @@ export const timezone = ExpoLocalization.timezone;
|
|
|
107
113
|
* The region code for your device that comes from the Region setting under Language & Region on iOS.
|
|
108
114
|
* This value is always available on iOS, but might return `null` on Android or web.
|
|
109
115
|
*
|
|
110
|
-
* @example
|
|
116
|
+
* @example
|
|
117
|
+
* `'US'`, `'NZ'`, `null`
|
|
111
118
|
*/
|
|
112
119
|
export const region = ExpoLocalization.region;
|
|
113
120
|
|
|
@@ -117,18 +124,21 @@ export const region = ExpoLocalization.region;
|
|
|
117
124
|
* These are returned in the order the user defines in their device settings.
|
|
118
125
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
119
126
|
* If needed, you can infer them from the current region using a lookup table.
|
|
120
|
-
* @example
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
* @example
|
|
128
|
+
* ```js
|
|
129
|
+
* [{
|
|
130
|
+
* "languageTag": "pl-PL",
|
|
131
|
+
* "languageCode": "pl",
|
|
132
|
+
* "textDirection": "ltr",
|
|
133
|
+
* "digitGroupingSeparator": " ",
|
|
134
|
+
* "decimalSeparator": ",",
|
|
135
|
+
* "measurementSystem": "metric",
|
|
136
|
+
* "currencyCode": "PLN",
|
|
137
|
+
* "currencySymbol": "zł",
|
|
138
|
+
* "regionCode": "PL",
|
|
139
|
+
* "temperatureUnit": "celsius"
|
|
140
|
+
* }]
|
|
141
|
+
* ```
|
|
132
142
|
*/
|
|
133
143
|
export const getLocales = ExpoLocalization.getLocales;
|
|
134
144
|
|
|
@@ -136,14 +146,15 @@ export const getLocales = ExpoLocalization.getLocales;
|
|
|
136
146
|
* List of user's preferred calendars, returned as an array of objects of type `Calendar`.
|
|
137
147
|
* Guaranteed to contain at least 1 element.
|
|
138
148
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
139
|
-
* @example
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
* @example
|
|
150
|
+
* ```js
|
|
151
|
+
* [{
|
|
152
|
+
* "calendar": "gregory",
|
|
153
|
+
* "timeZone": "Europe/Warsaw",
|
|
154
|
+
* "uses24hourClock": true,
|
|
155
|
+
* "firstWeekday": 1
|
|
156
|
+
* }]
|
|
157
|
+
* ```
|
|
147
158
|
*/
|
|
148
159
|
export const getCalendars = ExpoLocalization.getCalendars;
|
|
149
160
|
|
|
@@ -154,18 +165,21 @@ export const getCalendars = ExpoLocalization.getCalendars;
|
|
|
154
165
|
* On the web currency and measurements systems are not provided, instead returned as null.
|
|
155
166
|
* If needed, you can infer them from the current region using a lookup table.
|
|
156
167
|
* If the OS settings change, the hook will rerender with a new list of locales.
|
|
157
|
-
* @example
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
* @example
|
|
169
|
+
* ```js
|
|
170
|
+
* [{
|
|
171
|
+
* "languageTag": "pl-PL",
|
|
172
|
+
* "languageCode": "pl",
|
|
173
|
+
* "textDirection": "ltr",
|
|
174
|
+
* "digitGroupingSeparator": " ",
|
|
175
|
+
* "decimalSeparator": ",",
|
|
176
|
+
* "measurementSystem": "metric",
|
|
177
|
+
* "currencyCode": "PLN",
|
|
178
|
+
* "currencySymbol": "zł",
|
|
179
|
+
* "regionCode": "PL",
|
|
180
|
+
* "temperatureUnit": "celsius"
|
|
181
|
+
* }]
|
|
182
|
+
* ```
|
|
169
183
|
*/
|
|
170
184
|
export function useLocales() {
|
|
171
185
|
const [key, invalidate] = useReducer((k) => k + 1, 0);
|
|
@@ -184,14 +198,15 @@ export function useLocales() {
|
|
|
184
198
|
* Guaranteed to contain at least 1 element.
|
|
185
199
|
* For now always returns a single element, but it's likely to return a user preference list on some platforms in the future.
|
|
186
200
|
* If the OS settings change, the hook will rerender with a new list of calendars.
|
|
187
|
-
* @example
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
* @example
|
|
202
|
+
* ```js
|
|
203
|
+
* [{
|
|
204
|
+
* "calendar": "gregory",
|
|
205
|
+
* "timeZone": "Europe/Warsaw",
|
|
206
|
+
* "uses24hourClock": true,
|
|
207
|
+
* "firstWeekday": 1
|
|
208
|
+
* }]
|
|
209
|
+
* ```
|
|
195
210
|
*/
|
|
196
211
|
export function useCalendars() {
|
|
197
212
|
const [key, invalidate] = useReducer((k) => k + 1, 0);
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
export type Localization = {
|
|
3
3
|
/**
|
|
4
4
|
* Three-character ISO 4217 currency code. Returns `null` on web.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* @example
|
|
6
|
+
* `'USD'`, `'EUR'`, `'CNY'`, `null`
|
|
7
7
|
*/
|
|
8
8
|
currency: string | null;
|
|
9
9
|
/**
|
|
10
10
|
* Decimal separator used for formatting numbers.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* @example
|
|
12
|
+
* `','`, `'.'`
|
|
13
13
|
*/
|
|
14
14
|
decimalSeparator: string;
|
|
15
15
|
/**
|
|
16
16
|
* Digit grouping separator used when formatting numbers larger than 1000.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* @example
|
|
18
|
+
* `'.'`, `''`, `','`
|
|
19
19
|
*/
|
|
20
20
|
digitGroupingSeparator: string;
|
|
21
21
|
/**
|
|
@@ -37,22 +37,22 @@ export type Localization = {
|
|
|
37
37
|
/**
|
|
38
38
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag),
|
|
39
39
|
* consisting of a two-character language code and optional script, region and variant codes.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* @example
|
|
41
|
+
* `'en'`, `'en-US'`, `'zh-Hans'`, `'zh-Hans-CN'`, `'en-emodeng'`
|
|
42
42
|
*/
|
|
43
43
|
locale: string;
|
|
44
44
|
/**
|
|
45
45
|
* List of all the native languages provided by the user settings.
|
|
46
46
|
* These are returned in the order that the user defined in the device settings.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* @example
|
|
48
|
+
* `['en', 'en-US', 'zh-Hans', 'zh-Hans-CN', 'en-emodeng']`
|
|
49
49
|
*/
|
|
50
50
|
locales: string[];
|
|
51
51
|
/**
|
|
52
52
|
* The region code for your device that comes from the Region setting under Language & Region on iOS.
|
|
53
53
|
* This value is always available on iOS, but might return `null` on Android or web.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* @example
|
|
55
|
+
* `'US'`, `'NZ'`, `null`
|
|
56
56
|
*/
|
|
57
57
|
region: string | null;
|
|
58
58
|
/**
|
|
@@ -60,8 +60,8 @@ export type Localization = {
|
|
|
60
60
|
* On Web time zone is calculated with Intl.DateTimeFormat().resolvedOptions().timeZone. For a
|
|
61
61
|
* better estimation you could use the moment-timezone package but it will add significant bloat to
|
|
62
62
|
* your website's bundle size.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
63
|
+
* @example
|
|
64
|
+
* `'America/Los_Angeles'`
|
|
65
65
|
*/
|
|
66
66
|
timezone: string;
|
|
67
67
|
};
|
|
@@ -69,12 +69,14 @@ export type Localization = {
|
|
|
69
69
|
export type Locale = {
|
|
70
70
|
/**
|
|
71
71
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
|
|
72
|
-
* @example
|
|
72
|
+
* @example
|
|
73
|
+
* `'en-US'`, `'es-419'`, `'pl-PL'`.
|
|
73
74
|
*/
|
|
74
75
|
languageTag: string;
|
|
75
76
|
/**
|
|
76
77
|
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) without the region code.
|
|
77
|
-
* @example
|
|
78
|
+
* @example
|
|
79
|
+
* `'en'`, `'es'`, `'pl'`.
|
|
78
80
|
*/
|
|
79
81
|
languageCode: string | null;
|
|
80
82
|
/**
|
|
@@ -84,23 +86,27 @@ export type Locale = {
|
|
|
84
86
|
/**
|
|
85
87
|
* Currency code for the locale.
|
|
86
88
|
* Is `null` on Web, use a table lookup based on region instead.
|
|
87
|
-
* @example
|
|
89
|
+
* @example
|
|
90
|
+
* `'USD'`, `'EUR'`, `'PLN'`.
|
|
88
91
|
*/
|
|
89
92
|
currencyCode: string | null;
|
|
90
93
|
/**
|
|
91
94
|
* Currency symbol for the locale.
|
|
92
95
|
* Is `null` on Web, use a table lookup based on region (if available) instead.
|
|
93
|
-
* @example
|
|
96
|
+
* @example
|
|
97
|
+
* `'$'`, `'€'`, `'zł'`.
|
|
94
98
|
*/
|
|
95
99
|
currencySymbol: string | null;
|
|
96
100
|
/**
|
|
97
101
|
* Decimal separator used for formatting numbers with fractional parts.
|
|
98
|
-
* @example
|
|
102
|
+
* @example
|
|
103
|
+
* `'.'`, `','`.
|
|
99
104
|
*/
|
|
100
105
|
decimalSeparator: string | null;
|
|
101
106
|
/**
|
|
102
107
|
* Digit grouping separator used for formatting large numbers.
|
|
103
|
-
* @example
|
|
108
|
+
* @example
|
|
109
|
+
* `'.'`, `','`.
|
|
104
110
|
*/
|
|
105
111
|
digitGroupingSeparator: string | null;
|
|
106
112
|
/**
|
|
@@ -113,7 +119,6 @@ export type Locale = {
|
|
|
113
119
|
* Ask for user preferences if possible.
|
|
114
120
|
*/
|
|
115
121
|
measurementSystem: `metric` | `us` | `uk` | null;
|
|
116
|
-
|
|
117
122
|
/**
|
|
118
123
|
* The temperature unit used in the locale.
|
|
119
124
|
* Returns `null` if the region code is unknown.
|
|
@@ -189,19 +194,21 @@ export type Calendar = {
|
|
|
189
194
|
*/
|
|
190
195
|
calendar: CalendarIdentifier | null;
|
|
191
196
|
/**
|
|
192
|
-
* True when current device settings use 24
|
|
197
|
+
* True when current device settings use 24-hour time format.
|
|
193
198
|
* Can be null on some browsers that don't support the [hourCycle](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
194
199
|
*/
|
|
195
200
|
uses24hourClock: boolean | null;
|
|
196
201
|
/**
|
|
197
202
|
* The first day of the week. For most calendars Sunday is numbered `1`, with Saturday being number `7`.
|
|
198
203
|
* Can be null on some browsers that don't support the [weekInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/weekInfo) property in [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.
|
|
199
|
-
* @example
|
|
204
|
+
* @example
|
|
205
|
+
* `1`, `7`.
|
|
200
206
|
*/
|
|
201
207
|
firstWeekday: Weekday | null;
|
|
202
208
|
/**
|
|
203
209
|
* Time zone for the calendar. Can be `null` on Web.
|
|
204
|
-
* @example
|
|
210
|
+
* @example
|
|
211
|
+
* `'America/Los_Angeles'`, `'Europe/Warsaw'`, `'GMT+1'`.
|
|
205
212
|
*/
|
|
206
213
|
timeZone: string | null;
|
|
207
214
|
};
|