# generaltranslation: General Translation Core SDK: requiresTranslation URL: https://generaltranslation.com/ja/docs/core/class/methods/locales/requires-translation.mdx --- title: requiresTranslation description: GT の requiresTranslation メソッドの API リファレンス --- ## 概要 `requiresTranslation` メソッドは、ソースロケールとターゲットロケールに基づいて、翻訳が必要かどうかを判定します。 ロケールコードを比較し、承認済みロケール一覧を踏まえて、ソースコンテンツの翻訳が必要かどうかを確認します。 *** ## リファレンス ### パラメータ ### パラメータの説明 | パラメータ | 説明 | | ----------------- | ----------------------------------------------------- | | `sourceLocale` | ソースのロケールコード。指定しない場合は、インスタンスの `sourceLocale` を使用します | | `targetLocale` | ターゲットのロケールコード。指定しない場合は、インスタンスの `targetLocale` を使用します | | `approvedLocales` | 承認済みのターゲットロケールの配列。指定しない場合は、インスタンスの `locales` 配列を使用します | | `customMapping` | ロケールの決定に使用するオプションのカスタムマッピング | ### 戻り値 `boolean` - 翻訳が必要な場合は `true`、そうでない場合は `false` ### 例外 * `Error` - sourceLocale が指定されておらず、インスタンスにも `sourceLocale` が設定されていない場合 * `Error` - targetLocale が指定されておらず、インスタンスにも `targetLocale` が設定されていない場合 *** ## 例 ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES', locales: ['en-US', 'es-ES', 'fr-FR', 'de-DE'] }); // 異なる言語は翻訳が必要 console.log(gt.requiresTranslation('en-US', 'es-ES')); // true console.log(gt.requiresTranslation('en-US', 'fr-FR')); // true // 同じ言語は翻訳不要 console.log(gt.requiresTranslation('en-US', 'en-US')); // false console.log(gt.requiresTranslation('es-ES', 'es-ES')); // false // 同じ言語の異なる方言は翻訳不要 console.log(gt.requiresTranslation('en-US', 'en-GB')); // false console.log(gt.requiresTranslation('es-ES', 'es-MX')); // false // ターゲットが承認済みロケールに含まれていない console.log(gt.requiresTranslation('en-US', 'it-IT')); // false(it-ITは承認済みロケールに含まれていない) ``` *** ## 注意点 * 完全一致だけでなく、ロケールの言語ファミリーも考慮します * 承認済みのロケール一覧に従います * ターゲットロケールが承認済みロケールに含まれていない場合 (一覧が指定されている場合) は、`false` を返します ## 次のステップ * [`isSameLanguage`](/docs/core/class/methods/locales/is-same-language) でロケール同士の関係を確認する * [`determineLocale`](/docs/core/class/methods/locales/determine-locale) で最適なロケールを特定する * [`isValidLocale`](/docs/core/class/methods/locales/is-valid-locale) でロケールが有効かどうかを検証する