Multiple languages in Sitecore

My previous post was about multi site solutions in Sitecore. Now I want to talk about multiple languages. Sitecore is capable of using more than one language in one site. Languages are defined under /sitecore/system/languages:

Languages in Sitecore


Switching language in a Sitecore solution can be done using the ?sc_Lang= parameter, but most solutions will create individual sites with different host names for each language, because the parameter sets the language in a session variable, which search engines cannot read.

Another approach is to use the Sitecore LinkManager to embed the language into the URL of the site. This solution is session-less and allows multiple languages in the same domain (the XML is not complete, but is shortened for readibility. See the Sitecore web.config when setting up your own site):

<linkManager defaultProvider="sitecore">
    <clear />
    <add name="sitecore" languageEmbedding="always" languageLocation="filePath" ... />

This setting create urls with the language in the file path. This (fictional) url points to the same page but in different languages:

Each language setting contains the ISO codes and regional codes for the language. Languages can be extracted using the Sitecore.Globalization.Language class, and the class also contains the CultureInfo for the language. Sitecore gets the CultureInfo from either the field “Regional ISO Code” or the item name (if the field is empty).

This function converts all languages defined in the current context to a list of CultureInfos:

using System.Collections.Generic;
using Sitecore.Globalization;
using System.Globalization;
using Sitecore.Collections;

private IEnumerable<CultureInfo> GetLanguages()
  LanguageCollection languages = LanguageManager.GetLanguages(Sitecore.Context.ContentDatabase);
  List<CultureInfo> cultureInfos = new List<CultureInfo>();
  foreach (Language language in languages)
  return cultureInfos;

You can also use the LanguageManager to convert a CultureInfo to a Sitecore Language:

Language sourceLanguage = LanguageManager.GetLanguage("da-DK", Sitecore.Context.ContentDatabase);

Languages are added to Sitecore items one by one and is individually versioned, so one item can contain 1 or more language versions even is several languages are defined in Sitecore:

Language Versions

Languages on one item

This little function returns true if an item contains a version for the current language:

public static bool HasContextLanguage(Item item)
  Item latestVersion = item.Versions.GetLatestVersion();
  return ((latestVersion != null) && (latestVersion.Versions.Count > 0));

This function is very handy if you have a multi language website and only some of your items has been translated into all languages.
Sitecore actually returns an item for a language even if there is no language version for that item. It does so because of all the shared fields (fields shared across all languages) must be readable for all languages. And all items have shared fields because most of the standard fields are shared.

If you wish to copy content from one language to another, you must create 2 items, one of each language and then copy from one item to the other:

// I have removed the usual asserts and try/catches to compress the code.
private void CopyLanguage(ID id, Language sourceLanguage, Language destinationLanguage)
  Item sourceLanguageItem = Sitecore.Context.ContentDatabase.GetItem(id, sourceLanguage);
  Item destinationLanguageItem = Sitecore.Context.ContentDatabase.GetItem(id, destinationLanguage);
  using (new SecurityDisabler())

    destinationLanguageItem["myField"].Value = sourceLanguageItem["myField"].Value;


So the final question is: Does Sitecore have a default language, that Sitecore falls back to, in case an item is not tarnslated? The answer is no. Any item can be displayed in any language. Fields that are not shared will be displayed as empty fields.

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in .net, c#, Sitecore 6 and tagged , , , . Bookmark the permalink.

7 Responses to Multiple languages in Sitecore

  1. Mark Knight says:

    Our site uses Sitecore CMS ( and is a multi-language site (4 different languages)
    Whilst you are correct in stating Sitecore does not have language fallback by default, our Partner agency, 3Sixty, HAVE successfully implemented language fallback on our site.
    – this is on both page level AND field level as we required.

    It allows us great flexibility and meets our requirement of having all content available on each language version of the site to assist speed of deployment
    – if ‘local’ language for page / field is not present, then English (our master language) is shown be default.

    So i would express caution in your last statement. Just because Sitecore does not have default fallback language out of the box, it does not mean that it is now possible to have this feature within a Sitecore site.

  2. John West says:

    You may want to set the system culture based on the language, for instance to control date and number formats.

    You may want to determine the language from browser preferences.

    You may want to implement a fallback language at the page level, but I would avoid fallback language at the field level (you generally don’t want to mix languages on a page).

    Some time ago, I wrote a post about these issues.!960125F1D4A59952!165.entry

    I can’t vouch for the code quality, but the information might be of use to someone.

  3. Scott says:

    If you do not want to hard code fields, here is some code that will help you accomplish that:

    private void CopyLanguage(ID id, Language sourceLanguage, Language destinationLanguage)
    Item sourceLanguageItem = master.GetItem(id, sourceLanguage);
    Item destinationLanguageItem = master.GetItem(id, destinationLanguage);
    using (new SecurityDisabler())

    //for each field in source, create in destination if it does not exist
    foreach (Field sf in sourceLanguageItem.Fields)
    if (sf.Name.Contains(“_”)) continue;

    destinationLanguageItem.Fields[sf.Name].Value = sf.Value;

  4. Pingback: Creating fallback values using the RenderField pipeline « Brian Pedersen’s Sitecore and .NET Blog

  5. Pingback: Sitecore Language selector – creating a country selector « Brian Pedersen’s Sitecore and .NET Blog

  6. Pingback: Sitecore links in multisite solutions – SiteResolving « Brian Pedersen’s Sitecore and .NET Blog

  7. Pingback: Sitecore cross-site and cross-language links resolved in 6.4.1 release 120113 « Brian Pedersen’s Sitecore and .NET Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s