react-native-localize
@amazon-devices/react-native-localize
is a library for using Localize React Native in React Native for Vega (RNK) apps. The library provides localization and internationalization support, allowing you to adapt your app to different languages, regions, and cultures.
Installation
To use the package, add the JavaScript library dependency in your app's package.json
as shown in the following example.
"dependencies": {
...
"@amazon-devices/react-native-localize": "~2.0.0"
}
Examples
Here's an example of how to use @amazon-devices/react-native-localize
.
import { getCurrencies, getLocales } from "@amazon-devices/react-native-localize";
console.log(getLocales());
console.log(getCurrencies());
API reference
getLocales()
Returns the user's preferred locales, in order.
Method type
type getLocales = () => Array<{
languageCode: string;
scriptCode?: string;
countryCode: string;
languageTag: string;
isRTL: boolean;
}>;
Example
import { getLocales } from "@amazon-devices/react-native-localize";
console.log(getLocales());
/* -> [
{ countryCode: "GB", languageTag: "en-GB", languageCode: "en", isRTL: false },
{ countryCode: "US", languageTag: "en-US", languageCode: "en", isRTL: false },
{ countryCode: "FR", languageTag: "fr-FR", languageCode: "fr", isRTL: false },
] */
getNumberFormatSettings()
Returns number formatting settings.
Method type
type getNumberFormatSettings = () => {
decimalSeparator: string;
groupingSeparator: string;
};
Example
import { getNumberFormatSettings } from "@amazon-devices/react-native-localize";
console.log(getNumberFormatSettings());
/* -> {
decimalSeparator: ".",
groupingSeparator: ",",
} */
getCurrencies()
Returns the user's preferred currency codes, in order.
Method type
type getCurrencies = () => string[];
Example
import { getCurrencies } from "@amazon-devices/react-native-localize";
console.log(getCurrencies());
// -> ["EUR", "GBP", "USD"]
getCountry()
Returns the user's current country code based on its device locale, not on its position.
Method type
type getCountry = () => string;
Example
import { getCountry } from "@amazon-devices/react-native-localize";
console.log(getCountry());
// -> "FR"
Latin American regions
Devices using Latin American regional settings return "UN" instead of "419", because "419" is not a standard country code.
getCalendar()
Returns the user's preferred calendar format.
Method type
type getCalendar = () =>
| "gregorian"
| "buddhist"
| "coptic"
| "ethiopic"
| "ethiopic-amete-alem"
| "hebrew"
| "indian"
| "islamic"
| "islamic-umm-al-qura"
| "islamic-civil"
| "islamic-tabular"
| "iso8601"
| "japanese"
| "persian";
Example
import { getCalendar } from "@amazon-devices/react-native-localize";
console.log(getCalendar());
// -> "gregorian"
getTemperatureUnit()
Returns the user's preferred temperature unit.
Method type
type getTemperatureUnit = () => "celsius" | "fahrenheit";
Example
import { getTemperatureUnit } from "@amazon-devices/react-native-localize";
console.log(getTemperatureUnit());
// -> "celsius"
getTimeZone()
Returns the user's preferred timezone based on its device settings, not on its position.
Method type
type getTimeZone = () => string;
Example
import { getTimeZone } from "@amazon-devices/react-native-localize";
console.log(getTimeZone());
// -> "Asia/Yerevan"
uses24HourClock()
Returns true
if the user prefers a 24 hour clock format, false
if the user prefers a 12 hour clock format.
Method type
type uses24HourClock = () => boolean;
Example
import { uses24HourClock } from "@amazon-devices/react-native-localize";
console.log(uses24HourClock());
// -> true
usesMetricSystem()
Returns true
if the user prefers the metric measurement system, false
if the user prefers imperial.
Method type
type usesMetricSystem = () => boolean;
Example
import { usesMetricSystem } from "@amazon-devices/react-native-localize";
console.log(usesMetricSystem());
// -> true
usesAutoDateAndTime()
Tells if the device enables the automatic date and time setting.
Method type
type usesAutoDateAndTime = () => boolean | undefined;
Example
import { usesAutoDateAndTime } from "@amazon-devices/react-native-localize";
console.log(usesAutoDateAndTime());
// -> false/true
usesAutoTimeZone()
Tells if the device enables the automatic time zone setting.
Method type
type usesAutoTimeZone = () => boolean | undefined;
Example
import { usesAutoTimeZone } from "@amazon-devices/react-native-localize";
console.log(usesAutoTimeZone());
// -> false
Supported versions
Package name | Amazon NPM library version | Vega OS build number | Vega SDK version | Release notes |
---|---|---|---|---|
@amazon-devices/react-native-localize |
2.0.1+3.0.4 | OS 1.1 (201010438050) |
0.20 |
Related topics
Last updated: Sep 30, 2025