Hide menu Last updated: Sep 21 2015

You can create a content type that implements the ILocalizable interface in several language versions. For example, pages and blocks have multilingual support while media and folders do not have multilingual support. For a content type that implements ILocalizable, you can define individual properties as culture-specific, and have different values for each language. Properties that are not culture-specific are common through the different language versions. The following example shows of a property that is decorated as culture-specific.

public virtual string Heading { get; set; }

Fallback and replacement settings

Use fallback settings when you have translated parts of a site. The site displays the translated parts, but displays parts that are not translated in the fallback language.

Either from the edit user interface or programmatically, you can define a language fallback and replacement rules for content, which are inherited by content below the content in the structure where you defined the setting. For example, if you define and enable the fallback language B to replace language A for some part of the structure, a request for content in language A returns the content in language B.

You can use replacement while you add a new language to a site but keep it inaccessible to visitors of the site until you have completed translation of the whole structure by disabling the fallback language. Apply fallback settings when content does not exist in a language or if the content is not published for that language.

Loading content

The LanguageLoaderOption controls how languages are handled during loading. The overload:

var content = Locate.ContentLoader().Get<IContent>(contentLink)

is equivalent to:

var content = Locate.ContentLoader().Get<IContent>(contentLink, new LoaderOptions() { LanguageLoaderOption.FallbackWithMaster() });

In this case, language is not specified so the content is loaded in the same language as the current request is routed to (ContentLanguage.PreferredCulture). It also uses a fallback, so that if the content does not exist or is not published in the language, it will fallback according to specified fallback rules with a final fallback to the master language. The master language is the language version where the common properties are saved; the first language version in which the content was created.

Use the overload that takes a CultureInfo to load a content in a specific langauge, as follows:

var content = Locate.ContentLoader().Get<IContent>(contentLink, CultureInfo.GetCultureInfo("sv"));

This is equivalent to:

var content = Locate.ContentLoader().Get<IContent>(contentLink, new LoaderOptions(){ LanguageLoaderOption.Specific(CultureInfo.GetCultureInfo("sv")) });

In this case, a fallback option is not specified so no fallback rules are applied.

You can pass in CultureInfo.InvariantCulture as CultureInfo, which returns the master language version. This is useful when no specific language version is required (such as when reading a language-neutral property like ParentLink) and it also is faster because fallback rules are not applied, as follows:

var master = Locate.ContentLoader().Get<IContent>(contentLink, CultureInfo.InvariantCulture);

Related topic