Configure language fallback
Configure language fallback in the configuration file
Depending on your Sitecore solution, you can make a few adjustments to your language fallback configuration.
If your solution relies on Sitecore’s content search (item buckets) and you want to use language fallback, you must set up the particular search index to handle item- or field-level fallback.
To do this:
Enable the relevant fallback modes by setting the inner value of the corresponding xml child element for the relevant search index to
true
.<index id="sitecore_master_index" …> … <enableItemLanguageFallback>true</enableItemLanguageFallback> <enableFieldLanguageFallback>true</enableFieldLanguageFallback> … </index>
Perform a full rebuild of the affected indexes.
Note
If your configuration file does not contain these elements, use the Sitecore.ContentSearch.Lucene.Index.Master.config
file as an example of how to apply them.
No data is added to the index if there is no version of the field in the fallback language. However, in this case, the Sitecore data API returns items with fallback field values, and therefore you should enforce version presence on these items.
In the the Sitecore.LanguageFallback.config
file, you can make changes to the following settings:
DefaultCacheSize
determines the default cache size that stores the language fallback field values. The default value is 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" />
If you want different cache sizes on different databases, you can use the following code sample. The sample is available in the configuration file.
<!-- EXAMPLE: Override the size of languageFallbackFieldValues cache per database --> <!-- <databases> <database id="master"> <cacheSizes hint="setting"> <languageFallbackFieldValues>20MB</languageFallbackFieldValues> </cacheSizes> </database> <database id="web"> <cacheSizes hint="setting"> <languageFallbackFieldValues>20MB</languageFallbackFieldValues> </cacheSizes> </database> </databases> -->
AllowVaryFallbackSettingsPerLanguage
enables you to have different fallback settings for the same field in different languages.The default value is false. If you enable this feature, the performance is considerably degraded.
<!-- 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" />