as

Settings
Sign out
Notifications
Alexa
Amazonアプリストア
AWS
ドキュメント
Support
Contact Us
My Cases
開発
設計と開発
公開
リファレンス
サポート

react-native-localize

react-native-localize

@amazon-devices/react-native-localizeは、Vega向けReact Native(RNK)アプリでLocalize React Nativeを使用するためのライブラリです。このライブラリにより、ローカリゼーションとインターナショナリゼーションの機能が提供され、アプリをさまざまな言語、地域、文化に適応させることができます。

インストール

このパッケージを使用するには、以下の例に示すように、アプリのpackage.jsonにJavaScriptライブラリの依存関係を追加します。

クリップボードにコピーしました。

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

@amazon-devices/react-native-localizeの使用方法の例を次に示します。

クリップボードにコピーしました。

import { getCurrencies, getLocales } from "@amazon-devices/react-native-localize";

console.log(getLocales());
console.log(getCurrencies());

APIリファレンス

getLocales()

ユーザーが選択しているロケールを順番に返します。

メソッドタイプ

クリップボードにコピーしました。

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

クリップボードにコピーしました。

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()

数値の書式の設定を返します。

メソッドタイプ

クリップボードにコピーしました。

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

クリップボードにコピーしました。

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

console.log(getNumberFormatSettings());
/* -> {
  decimalSeparator: ".",
  groupingSeparator: ",",
} */

getCurrencies()

ユーザーが選択している通貨コードを順番に返します。

メソッドタイプ

クリップボードにコピーしました。

type getCurrencies = () => string[];

クリップボードにコピーしました。

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

console.log(getCurrencies());
// -> ["EUR", "GBP", "USD"]

getCountry()

デバイスの位置ではなくロケールに基づいて、ユーザーの現在の国コードを返します。

メソッドタイプ

クリップボードにコピーしました。

type getCountry = () => string;

クリップボードにコピーしました。

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

console.log(getCountry());
// -> "FR"

ラテンアメリカ地域

ラテンアメリカの地域設定を使用するデバイスでは、「419」は標準の国コードではないため、代わりに「UN」が返されます。


getCalendar()

ユーザーが選択しているカレンダー形式を返します。

メソッドタイプ

クリップボードにコピーしました。

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

クリップボードにコピーしました。

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

console.log(getCalendar());
// → "gregorian"

getTemperatureUnit()

ユーザーが選択している温度単位を返します。

メソッドタイプ

クリップボードにコピーしました。

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

クリップボードにコピーしました。

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

console.log(getTemperatureUnit());
// → "celsius"

getTimeZone()

デバイスの位置ではなく設定に基づいて、ユーザーが選択しているタイムゾーンを返します。

メソッドタイプ

クリップボードにコピーしました。

type getTimeZone = () => string;

クリップボードにコピーしました。

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

console.log(getTimeZone());
// → "Asia/Yerevan"

uses24HourClock()

ユーザーが時刻の形式として24時間形式を選択している場合はtrue、12時間形式を選択している場合はfalseを返します。

メソッドタイプ

クリップボードにコピーしました。

type uses24HourClock = () => boolean;

クリップボードにコピーしました。

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

console.log(uses24HourClock());
// → true

usesMetricSystem()

ユーザーが測定体系としてメートル法を選択している場合はtrue、ヤード・ポンド法を選択している場合はfalseを返します。

メソッドタイプ

クリップボードにコピーしました。

type usesMetricSystem = () => boolean;

クリップボードにコピーしました。

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

console.log(usesMetricSystem());
// → true

usesAutoDateAndTime()

デバイスが日付と時刻の自動設定を有効にしているかどうかを示します。

メソッドタイプ

クリップボードにコピーしました。

type usesAutoDateAndTime = () => boolean | undefined;

クリップボードにコピーしました。

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

console.log(usesAutoDateAndTime());
// → false/true

usesAutoTimeZone()

デバイスがタイムゾーンの自動設定を有効にしているかどうかを示します。

メソッドタイプ

クリップボードにコピーしました。

type usesAutoTimeZone = () => boolean | undefined;

クリップボードにコピーしました。

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

console.log(usesAutoTimeZone());
// → false

サポートされているバージョン

パッケージ名 Amazon NPMライブラリのバージョン Vega OSのビルド番号 Vega SDKバージョン リリースノート
@amazon-devices/react-native-localize 2.0.1+3.0.4 OS 1.1 (201010438050) 0.20  

Last updated: 2025年9月30日