📚 Product Knowledge
Globalization
📖 Docs

Globalization and Multilingual Content - Optimizely CMS 12

Exam Area: Content Area 1 – Product Knowledge (15%)
Reference: https://docs.developers.optimizely.com/content-management-system/docs/globalization


1. Globalization in Optimizely CMS

Optimizely CMS has built-in multi-language support. Each content item can have multiple language versions.


2. Configuring Languages

In Admin View:

  1. Go to AdminWebsite Languages
  2. Add a new language (e.g., en, vi, fr)
  3. Set the default language

In Code (appsettings.json):

{
  "EPiServer": {
    "CMS": {
      "DefaultLanguage": "en"
    }
  }
}

In Startup.cs:

services.Configure<RequestLocalizationOptions>(options =>
{
    var supportedCultures = new[] { "en", "vi", "fr" };
    options.SetDefaultCulture(supportedCultures[0])
           .AddSupportedCultures(supportedCultures)
           .AddSupportedUICultures(supportedCultures);
});

3. CultureSpecific Attribute

Properties can be:

[ContentType(DisplayName = "Article Page", GUID = "...")]
public class ArticlePage : PageData
{
    // Different value per language
    [CultureSpecific]
    [Display(Name = "Heading")]
    public virtual string Heading { get; set; }

    // Shared – same value for all languages
    // (no [CultureSpecific])
    [Display(Name = "Sort Order")]
    public virtual int SortOrder { get; set; }
}

4. Fallback Language

If content does not yet have a translation for the requested language, CMS can use a fallback:

// Configure fallback
services.Configure<LanguageOptions>(options =>
{
    options.FallbackBehavior = LanguageFallback.FallbackToMaster;
});

Fallback modes:


5. Retrieving Content by Language

// Get content in a specific language
var languageSelector = new LanguageSelector("vi");
var vietnameseContent = _contentRepository.Get<ArticlePage>(
    contentLink, languageSelector);

// Get all language versions
var allVersions = _contentRepository.GetLanguageBranches<ArticlePage>(contentLink);

// Get in the current language
var currentContent = _contentRepository.Get<ArticlePage>(contentLink);

6. Localizing the UI (XML Resources)

CMS uses XML files to localize the interface:

<!-- lang/en.xml -->
<languages>
  <language name="English" id="en">
    <contenttypes>
      <articlepage>
        <name>Article Page</name>
        <description>A page for articles</description>
        <properties>
          <heading>
            <caption>Heading</caption>
            <help>Enter the page heading</help>
          </heading>
        </properties>
      </articlepage>
    </contenttypes>
  </language>
</languages>

7. Optimizely Languages Add-on

This add-on package provides:

NuGet: EPiServer.Languages


8. Multisite with Multiple Languages

// Site definition with languages
var siteDefinition = new SiteDefinition
{
    Name = "My Site",
    SiteUrl = new Uri("https://example.com"),
    StartPage = ContentReference.RootPage
};

// Configure languages for the site
siteDefinition.Languages.Add(new CultureInfo("en"));
siteDefinition.Languages.Add(new CultureInfo("vi"));

9. Language Routing

https://example.com/en/products/   → English
https://example.com/vi/san-pham/   → Vietnamese
https://example.com/fr/produits/   → French

Review Questions

  1. Which attribute marks a property as culture-specific? ([CultureSpecific])
  2. Without [CultureSpecific], what is the property value? (Shared/Language neutral)
  3. How do you retrieve content in a specific language? (Use LanguageSelector)
  4. What are XML resources used for in CMS? (Localize UI labels and help texts)
  5. What does FallbackToMaster mean? (Use the master language when a translation does not exist)