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日

