Wednesday, 31 May 2017

Language fallback in Sitecore

Language fallback
In a Multilanguage solution, you can use the language fallback functionality to control which items or fields that you want to reuse content from another language, and which items and fields that you want to translate.
You specify a fallback language for the languages in your Sitecore solution and enable language fallback on the relevant items or fields. If a version does not exist in a given language, language fallback activates, and the item or field value is displayed in the fallback language instead.
You can also set up a chain of language fallback. For example, you can specify the language en-NZ to fall back to en-AU and en-AU to fall back to en. If the version in en-AU does not exist for a particular item or field, then the version in en-NZ falls back to the version in en.



Item-level language fallback

Item-level fallback enables you to set up an 'empty' item version in a given language so that it falls back to another language version, including all its fields. In this way, you can launch a new language version of your entire website without creating any items in the new language in the Content database.

Field-level language fallback


Field-level fallback enables you to specify on a single field, which field values that you want to localize and which field values that you want to fall back to another language.

Enable and set up language fallback

To use the language fallback functionality, you enable either item-level or field-level fallback on the relevant sites and on the relevant items, fields, or templates

Enable site-level language fallback

To enable site-level language fallback:
  • Open \Website\App_Config\Include\Sitecore.LanguageFallback.config and set the following attributes to true:
    • enableItemLanguageFallback
    • enableFieldLanguageFallback
You must enable the attributes on the shell and on each of the relevant websites.
<sites>
      <site name="shell">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
      </site>
      <site name="website">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
      </site>
</sites>
In multisite environments where you only want to enable language fallback on a subset of the websites, you need to create a specific shell site for each website where you want the language fallback feature enabled.

Specify the fallback language rules


To specify the fallback language for a language definition item:
  1. In the Content Editor, in the content tree, navigate to and click the language definition item that you want to specify the fallback language for. The language definition items are located in sitecore/system/Languages.
2.      In the Data section, in the Fallback Language field, enter the name of the relevant language, for example, en-AU.


Enable item-level fallback


To enable item-level fallback:
  1. In the content tree, navigate to the relevant item.
  2. To enable language fallback on a template, navigate to the relevant template and click the _Standard Values item.

  1. On the Content tab, in the Advanced section, select Enable Item Fallback.


Enable field-level fallback


To enable field-level fallback:
  1. In the content tree, navigate to the relevant template and click the field definition item that you want to enable field-level fallback for.
  1. In the Data section of the item, select:
    • Enable field level fallback – to enable language fallback for all the language versions of the current field. This applies to all the currently available language versions of the field and any new language versions that you create.

    • Enable versioned field level fallback – to enable language fallback for only the current language version of the field.
To allow different fallback settings for the same field in different languages (versioned fallback), in the Sitecore.LanguageFallback.config file, you must set the configuration setting LanguageFieldFallback.AllowVaryFallbackSettingsPerLanguage to true. However, this degrades performance considerably.



References:


No comments:

Post a Comment

Thanks for your comment