as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

expo-localization

@amazon-devices/expo-localization provides an interface for native user localization information.

This library provides the getCalendars() and getLocales() method and their corresponding hooks, which return specific information about a user's locale settings, for example languageCode, uses24HourClock, currencyCode, and textDirection. The library doesn't provide any methods 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

  1. Add the JavaScript library dependency in the package.json file.

    Copied to clipboard.

     "dependencies": {
     ...
     "@amazon-devices/expo-localization": "~2.0.1",
     "@amazon-devices/keplerscript-turbomodule-api": "~1.0.0",
     ...
     }
    
  2. Reinstall dependencies using the npm install command.

Examples

The example below demonstrates how to retrieve a user's language code.

Copied to clipboard.

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

See the documentation page for information about this library and API reference: Official Expo documentation for expo-localization.

Constants

Constant Description
locale An IETF BCP 47 language tag, consisting of a two-character language code and optional script, region, and variant codes. Consider using Localization.getLocales() for a list of user preferred locales instead.

Hooks

Hook Description
useCalendars Lists a user's preferred calendars and returns 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 Lists a user's locales and returns 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 measurement systems aren't provided, instead they're returned as null. If needed, you can infer currencies and measurements 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 Supported
getCalendars Lists a user's preferred calendars and returns 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. ✅ Yes
getLocales Lists 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 measurement systems aren't provided, instead they're returned as null. If needed, you can infer currencies and measurements from the current region using a lookup table. ✅ Yes
getLocalizationAsync Deprecated. ❌ No

Known issues and limitations

  • The region field on Localization type is always null on Vega.

  • Functions useLocales(), useCalendars(), getCalendars(), and getLocales() always return an array with one item in it, while other platforms might return an empty array or multiple valid locales/calendars.

Supported versions

Package Version Based On @amazon-devices/react-native-kepler version
2.0.x 14.6.0 2.0.x

Supported Third-Party Libraries and Services.


Last updated: Sep 30, 2025