expo-localization
@amazon-devices/expo-localization provides an interface for native user localization information.
This library provides the getCalendars() and getLocales() methods and their corresponding hooks, which return specific information about a user's locale settings, for example languageCode, uses24HourClock, currencyCode and textDirection. No methods are provided for formatting text or values. Hooks trigger a re-render when the app locale changes.
This library is system-deployed and available to React Native for Vega apps without a separate installation process. This autolinking library connects to your app at runtime. Compatibility is guaranteed only between the library and the version of React Native for Vega for which it is built.
Installation
- Add the JavaScript library dependency in the
package.jsonfile."dependencies": { ... "@amazon-devices/expo-localization": "~2.0.0", "@amazon-devices/keplerscript-turbomodule-api": "~1.0.0", ... } - Reinstall dependencies using the
npm installcommand.
Examples
This example demonstrates how to retrieve a user's language code.
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {useLocales, useCalendars} from '@amazon-devices/expo-localization';
export const App = () => {
const locales = useLocales();
const calendars = useCalendars();
return (
<View style={styles.container}>
<Text style={styles.text}>useLocales():</Text>
<Text style={styles.text}>{JSON.stringify(locales, null, 2)}</Text>
<Text style={styles.text}>useCalendars():</Text>
<Text style={styles.text}>{JSON.stringify(calendars, null, 2)}</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
backgroundColor: 'white',
},
text: {
color: 'black',
fontSize: 32,
},
});
API reference
Check out the dedicated documentation page for info about this library and API reference: Official Expo documentation for expo-localization.
Constants
| Constant | Description |
|---|---|
locale |
Consider using Localization.getLocales() for a list of user preferred locales instead. An IETF BCP 47 language tag, consisting of a two-character language code and optional script, region and variant codes |
Hooks
| Hook | Description |
|---|---|
useCalendars |
Provides a list of a user's preferred calendars, returned as an array of objects of type Calendar. Guaranteed to contain at least one element. Always returns a single element, but it's likely to return a user preference list on some platforms in the future. If the OS settings change, the hook rerenders with a new list of calendars. |
useLocales |
Provides a list of a user's locales, returned as an array of objects of type Locale. Guaranteed to contain at least one element. These are returned in the order the user defines in their device settings. On the web, currency and measurements systems aren't provided, instead, they're returned as null. If needed, you can infer them from the current region using a lookup table. If the OS settings change, the hook rerenders with a new list of locales. |
Methods
| Method | Description |
|---|---|
getCalendars |
List of user's preferred calendars, returned as an array of objects of type Calendar. Guaranteed to contain at least one element. Always returns a single element, but it's likely to return a user preference list on some platforms in the future. |
getLocales |
List of user's locales, returned as an array of objects of type Locale. Guaranteed to contain at least one element. These objects are returned in the order the user defines in their device settings. On the web, currency and measurements systems aren't provided, instead, they're returned as null. If needed, you can infer them from the current region using a lookup table. |
Known issues and limitations
-
The
regionfield onLocalizationtype is always null on Vega. -
Functions
useLocales(),useCalendars(),getCalendars()andgetLocales()always return an array with one item in it, while other platforms could return empty arrays or multiple valid locales/calendars. -
The deprecated constants and method
getLocalizationAsync()aren't supported on Vega.
Supported versions
| Package Version | Based On | @amazon-devices/react-native-kepler version |
|---|---|---|
| 2.0.x | 14.6.0 | 2.0.x |
Related topics
For information on additional libraries, see Supported Third-Party Libraries and Services.
Last updated: Sep 30, 2025

