The language fallback supports both at Item level and at field level and supports a chained fallback mode, where languages can fall back multiple times based on the associated langauges versions.
How does it work
The language fallback allows a developer to specify a default fallback language (for each of the language setting item in Sitecore) to use, when a visitor at the website request content that have not been created for the requested language version.
Template level
The “Tempalte Item” contains two new checkboks fields for handling the fallback language at item-level. The first checkbox “Enable Item Fallback” managing whether to use the fallback language, if the current item has no language version created for the requested language. The second checkbox “Enforce Version Presence” controls whether Sitecore should treat the specific item as non-existent, if the specific item has no versions created at the requested language.
Template Field level
The “Template Field Item” contains two new checkbox fields for handling the fallback language at field level, both placed at the “Data” field section. The first checkbox field “Enable Versioned Language Fallback” enables field-level fallback for only the current language version of the specific field. The second checkbox field “Enable Shared Language Fallback” enables the field-level fallback for the specific field in all languages.
Specify the fallback language
To specify a fallback language for a specific language, Sitecore has added a field at the Language Setting Item in Sitecore (placed at: Sitecore/system/Languages/) called “Fallback Langauge”. If none is selected, the language has no fallback language.
Enabling the fallback language features
Sitecore has added a new config file handling the language fallback settings. It is located at /App_Config/Sitecore.LangauageFallback.config. By default, the fallback language feature is disabled. To enable the fallback language, open the config file, find the two new site attributes, “enableItemLanguageFallback” and “EnableFieldLanguageFallback” respectively and set the attribute value to “true” (notice, the fallback feature is site specific):
<!-- ENABLE ITEM AND LANGUAGE FALLBACK PER SITE Using attribute patching below you can pick which fallback mode to enable (item-level or field-level or both) for each site Consult official documentation on how to enable fallback feature in complex multi-site environments. --> <sites> <site name="shell"> <patch:attribute name="enableItemLanguageFallback">false</patch:attribute> <patch:attribute name="enableFieldLanguageFallback">false</patch:attribute> </site> <site name="website"> <patch:attribute name="enableItemLanguageFallback">true</patch:attribute> <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute> </site> </sites>
1 comment:
good one!
Post a Comment