as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

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.

Copied to clipboard.

    "dependencies": {
         ...
         "@amazon-devices/react-native-localize": "~2.0.0"
    }

Examples

Here's an example of how to use @amazon-devices/react-native-localize.

Copied to clipboard.

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

Copied to clipboard.

type getLocales = () => Array<{
  languageCode: string;
  scriptCode?: string;
  countryCode: string;
  languageTag: string;
  isRTL: boolean;
}>;

Example

Copied to clipboard.

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

Copied to clipboard.

type getNumberFormatSettings = () => {
  decimalSeparator: string;
  groupingSeparator: string;
};

Example

Copied to clipboard.

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

Copied to clipboard.

type getCurrencies = () => string[];

Example

Copied to clipboard.

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

Copied to clipboard.

type getCountry = () => string;

Example

Copied to clipboard.

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

Copied to clipboard.

type getCalendar = () =>
  | "gregorian"
  | "buddhist"
  | "coptic"
  | "ethiopic"
  | "ethiopic-amete-alem"
  | "hebrew"
  | "indian"
  | "islamic"
  | "islamic-umm-al-qura"
  | "islamic-civil"
  | "islamic-tabular"
  | "iso8601"
  | "japanese"
  | "persian";

Example

Copied to clipboard.

import { getCalendar } from "@amazon-devices/react-native-localize";

console.log(getCalendar());
// -> "gregorian"

getTemperatureUnit()

Returns the user's preferred temperature unit.

Method type

Copied to clipboard.

type getTemperatureUnit = () => "celsius" | "fahrenheit";

Example

Copied to clipboard.

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

Copied to clipboard.

type getTimeZone = () => string;

Example

Copied to clipboard.

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

Copied to clipboard.

type uses24HourClock = () => boolean;

Example

Copied to clipboard.

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

Copied to clipboard.

type usesMetricSystem = () => boolean;

Example

Copied to clipboard.

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

Copied to clipboard.

type usesAutoDateAndTime = () => boolean | undefined;

Example

Copied to clipboard.

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

Copied to clipboard.

type usesAutoTimeZone = () => boolean | undefined;

Example

Copied to clipboard.

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  

Last updated: Sep 30, 2025