# General Translation Platform: getLocaleProperties URL: https://generaltranslation.com/ja/docs/platform/core/reference/gt-class-methods/locales/get-locale-properties.mdx --- title: getLocaleProperties description: ロケールの言語、スクリプト、リージョン、direction に関する詳細なプロパティを返します。getLocaleProperties の API リファレンス。 --- [GT](/docs/platform/core/reference/gt-class/constructor) インスタンスで、ロケールコードの包括的なプロパティを取得します。表示名、言語、スクリプト、リージョン情報、emoji flag などが含まれます。General Translation は、充実した国際化ユーザーインターフェースの構築に必要なデータを含む完全な [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトを返します。 ## 概要 [#overview] [`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスに対して、必要に応じてロケールコードを指定して `getLocaleProperties` を呼び出します。省略した場合は、そのインスタンスの `targetLocale` が使用されます。 ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); const props = gt.getLocaleProperties('fr-CA'); console.log(props.name); // "Canadian French" console.log(props.nativeName); // "français canadien" console.log(props.emoji); // "🇨🇦" ``` シグネチャ: ```typescript getLocaleProperties(locale?: string): LocaleProperties ``` *注: `getLocaleProperties` はローカルで実行されるため、API Key は不要です。`locale` を省略するとインスタンスの `targetLocale` が使われ、表示名にはインスタンスの `sourceLocale` が反映されます。`GT` インスタンスを使わないルックアップについては、スタンドアロンの [`getLocaleProperties`](/docs/platform/core/reference/utility-functions/locales/get-locale-properties) を参照してください。* ## 仕組み [#how-it-works] * **最大化形式と最小化形式。** このメソッドは、ロケールコードの最大化形式 (推定されるスクリプトとリージョンを追加したもの) と最小化形式の両方を導出します。 * **表示言語。** すべての表示名は、インスタンスの `sourceLocale` 設定に従います。 * **カスタムマッピング の優先順位。** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) で定義されたプロパティは、標準の `Intl` API より優先されます。 * **ロケールのフォールバック。** `locale` を省略した場合は、インスタンスの `targetLocale` が使用されます。 * **ロケール未指定。** ロケールが指定されておらず、かつインスタンスに `targetLocale` が設定されていない場合は、`Error` をスローします。 ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 任意 | デフォルト | | ------------------- | -------------------------- | -------- | -- | ------------------- | | [`locale`](#locale) | プロパティを取得する BCP-47 ロケールコード。 | `string` | はい | `this.targetLocale` | ### `locale` [#locale] **Type** `string` · **任意** · **デフォルト** `this.targetLocale` プロパティの取得対象となる BCP-47 ロケールコード (例: `"de-AT"`) 。指定しない場合は、このインスタンスの `targetLocale` が使用されます。 ## 戻り値 [#returns] **Type** [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) ロケールを包括的に表すオブジェクトです。 * `code`: 完全なロケールコード (例: `"de-AT"`) 。 * `name`: 表示言語での言語名 (例: `"Austrian German"`) 。 * `nativeName`: ロケールのネイティブ言語での言語名 (例: `"Österreichisches Deutsch"`) 。 * `languageCode`, `languageName`, `nativeLanguageName`: ベース言語の情報。 * `nameWithRegionCode`, `nativeNameWithRegionCode`: リージョンコード付きの言語名 (例: `"German (AT)"`) 。 * `regionCode`, `regionName`, `nativeRegionName`: リージョン情報。 * `scriptCode`, `scriptName`, `nativeScriptName`: スクリプトに関する情報。 * `maximizedCode`, `maximizedName`, `nativeMaximizedName`: 想定されるスクリプトとリージョンを含む最大化形式。 * `minimizedCode`, `minimizedName`, `nativeMinimizedName`: 最小化形式。 * `emoji`: ロケールのリージョンを表す国旗または代表的な絵文字。 ロケールが指定されておらず、かつインスタンスに `targetLocale` が設定されていない場合は、`Error` をスローします。 ## 例 [#examples] ```typescript // 基本的な使い方 const gt = new GT({ sourceLocale: 'en', targetLocale: 'fr' }); // ターゲットロケールのプロパティを取得 const props = gt.getLocaleProperties(); console.log(props.name); // "French" console.log(props.nativeName); // "français" console.log(props.languageCode); // "fr" console.log(props.regionCode); // "FR" console.log(props.emoji); // "🇫🇷" // 他のロケールのプロパティを取得 const germanProps = gt.getLocaleProperties('de-AT'); console.log(germanProps.name); // "Austrian German" console.log(germanProps.nativeName); // "Österreichisches Deutsch" console.log(germanProps.regionName); // "Austria" console.log(germanProps.nativeRegionName); // "Österreich" ``` ## メモ [#notes] * すべての表示名は、インスタンスの `sourceLocale` 設定に従います。 * カスタムマッピングのプロパティは、標準の `Intl` API より優先されます。