---
title: "言語のフォールバック設定を微調整しましょう"
slug: "fine-tune-your-language-fallback-configuration"
abstract: "構成ファイルを使って言語のフォールバック設定を調整してください。"
---
# 言語のフォールバック設定を微調整しましょう

Sitecoreのソリューションによっては、検索インデックスやパッチファイルを使った言語フォールバック設定など、言語フォールバックの設定をいくつか調整できます。

## 言語フォールバックを処理するための検索インデックスを設定しましょう

もしあなたのソリューションがSitecoreのコンテンツ検索(アイテムバケット)に依存していて、言語フォールバックを使いたい場合は、アイテムレベルまたはフィールドレベルのフォールバックに対応する特定の検索インデックスを設定する必要があります。

言語のフォールバックを処理する検索インデックスを設定するには:

1.  関連する検索インデックスの以下のXML子要素を追加(またはパッチ)し、その内部値をtrueに設定することで、関連するフォールバックモードを有効にします。これらの変更は [パッチファイル](https://doc.sitecore.com/xp/development/use-a-patch-file-to-customize-the-sitecore-configuration/use-a-patch-file-to-customize-the-sitecore-configuration.md "Use a patch file to customize the Sitecore configuration")を使って適用してください。パッチファイルはどんな名前でも構いませんが、ソースコードの /platform/ フォルダに入れる必要があります。
    
    <index id="sitecore\_master\_index" …>
    …
     <enableItemLanguageFallback>true</enableItemLanguageFallback>
     <enableFieldLanguageFallback>true</enableFieldLanguageFallback>
    …
    </index>
    
2.  影響を受けたインデックスの完全な再構築を行います。
    

> !注設定ファイルにこれらの要素が含まれていない場合は、Sitecore.ContentSearch.Solr.Index.Master.configファイルを例として適用してください。

フォールバック言語にフィールドのバージョンがなければ、インデックスにはデータが追加されません。しかし、この場合、SitecoreのデータAPIはフォールバックフィールド値付きのアイテムを返すため、これらのアイテムにバージョンプレゼンスを強制することを推奨します。

## Sitecoreの設定をしてください。LanguageFallback.configファイル

[パッチファイル](https://doc.sitecore.com/xp/development/use-a-patch-file-to-customize-the-sitecore-configuration/use-a-patch-file-to-customize-the-sitecore-configuration.md "Use a patch file to customize the Sitecore configuration")を使ってデフォルトを上書きすることで、以下の設定を設定できますSitecore.LanguageFallback.config。パッチファイルはどんな名前でも構いませんが、ソースコードの/platform/フォルダに入れる必要があります。

-   DefaultCacheSize - 言語のフォールバックフィールド値を格納するデフォルトのキャッシュサイズを決定する。デフォルト値は20MBです。
    
    <!-- CACHING - LANGUAGE FALLBACK FIELD VALUES - DEFAULT CACHE SIZE
     Determines the default size of the cache that stores the language fallback field values.
     Specify the value in bytes or append the value with KB, MB or GB.
     Default value: 20MB.
     -->
     <setting name="Caching.LanguageFallbackFieldValues.DefaultCacheSize" value="20MB" />
    
    特定のデータベースで異なるキャッシュサイズを使いたい場合は、以下のコードサンプルをご利用ください。サンプルは設定ファイルで入手可能です。
    
    <!-- EXAMPLE: Override the size of languageFallbackFieldValues cache per database -->
     <!--
     <databases>
     <database id="master">
     <cacheSizes hint="setting">
     <languageFallbackFieldValues>20MB</languageFallbackFieldValues>
     </cacheSizes>
     </database>
     </databases>
     -->
    
-   AllowVaryFallbackSettingsPerLanguage - 同じフィールドに対して異なる言語で異なるフォールバック設定を設定できるようにします。デフォルト値はfalseです。
    
    > !重要この機能を有効にすると、パフォーマンスが大幅に低下します。
    
    <!-- LANGUAGE FIELD FALLBACK - ALLOW VARY FALLBACK SETTINGS PER LANGUAGE
     If set to 'true', then values from both versioned 'Enable Language Fallback' and shared 'Enable Shared Language Fallback' checkbox fields
     on the field definition item are used to determine whether language fallback functionality should be enabled for the corresponding field.
     It allows you to have different fallback settings for the same field in different content languages.
     Example: when 'en-CA' tries to fallback to 'en', the checkbox field will be retrieved from the field definition item in 'en-CA',
     thus such version should exist. If retrieved value is 'false', then the 'Enable Shared Language Fallback' checkbox field is used.
     Note: enabling this feature has negative impact on performance.
     If set to 'false', only the shared 'Enable Shared Language Fallback' checkbox field on the field definition item is used to determine whether
     language fallback functionality should be enabled for the corresponding field.
     Default value: false.
     -->
     <setting name="LanguageFieldFallback.AllowVaryFallbackSettingsPerLanguage" value="false" />