Skip to main content

Outline

At a glance:
  • What this covers: Reading language branch definitions (which languages exist, active/master status) using ILanguageBranchRepository.
  • What it is not: Content translation itself - localized content is handled via IContentLoader / IContentRepository with CultureInfo and loader options.
  • Common use cases: Language selectors, reporting, automation that iterates through configured languages, sanity checks for environment parity.
  • Key reminder: Language branches define "available languages"; content versions define "localized content."

Introduction

Optimizely CMS 12 is designed for multilingual websites, where the same content item can exist in multiple language versions. Editors typically manage language configuration in Admin views, but developers still need to understand how language branches are represented in the platform - especially when building custom language pickers, running localization audits, or implementing automated workflows that iterate over all configured languages.

This page focuses on the developer-facing model: what a LanguageBranch is, how to read language branches through ILanguageBranchRepository, and how that relates to loading and saving content in specific languages.

1. Core concepts: what a language branch represents

A language branch is Optimizely's representation of a configured language for your site(s). It describes the language as a configuration entity (culture, display name, active/master status) - not the translated content itself.

Key properties you'll commonly inspect include:

  • Culture - the CultureInfo (for example en-US, sv-SE).
  • Name - the display name of the language branch.
  • ID - internal identifier.
  • IsActive - whether the branch is enabled for use.
  • IsMaster - whether the branch is the master language.

Administrators typically manage branches under CMS admin configuration views (for example, language branch management and website language mappings). From code, you usually treat branches as read-mostly configuration.

2. Obtaining ILanguageBranchRepository

ILanguageBranchRepository provides access to configured language branches. As with other Optimizely services, use dependency injection.

C#
using EPiServer.DataAbstraction; public class LanguageService { private readonly ILanguageBranchRepository _languageBranchRepository; public LanguageService(ILanguageBranchRepository languageBranchRepository) { _languageBranchRepository = languageBranchRepository; } }

3. Scenario 1: Listing all configured language branches

Listing language branches is useful for building a custom language selector, generating localization reports, or validating that environments (Integration/Preproduction/Production) share the same configured languages.

C#
using System; using System.Linq; using EPiServer.DataAbstraction; public class LanguageService { private readonly ILanguageBranchRepository _languageBranchRepository; public LanguageService(ILanguageBranchRepository languageBranchRepository) { _languageBranchRepository = languageBranchRepository; } public void ListAllBranches() { var branches = _languageBranchRepository.ListAll(); if (!branches.Any()) { Console.WriteLine("No language branches configured."); return; } Console.WriteLine("Configured language branches:"); foreach (var b in branches) { Console.WriteLine($"- {b.Culture.Name}"); Console.WriteLine($" Name: {b.Name}"); Console.WriteLine($" ID: {b.ID}"); Console.WriteLine($" Active: {b.IsActive}"); Console.WriteLine($" Master: {b.IsMaster}"); } } }

Typical branch list pitfalls

Select a pitfall to expand and read the details.

Configured vs enabled

A branch can exist but be inactive. Don't assume "listed" means "usable." Always filter by IsActive when you need the set of languages that editors and automation should operate against.

Environment drift

Language configuration can differ across environments if not governed - especially in long-lived projects where admin changes in Production are not mirrored back to Integration. Treat language branch setup as infrastructure configuration and include it in environment parity checks.

Site mapping in multi-site setups

Multi-site setups may use only a subset of branches per site. A branch existing in the repository does not mean it is mapped to - or usable by - a specific site. Verify site-to-language mappings separately when building language selectors for a particular site.

4. Scenario 2: Getting a specific language branch

You may need to retrieve a particular branch to check whether it's active, whether it's the master language, or to safely obtain a CultureInfo object for downstream content operations.

C#
using System; using System.Globalization; using EPiServer.DataAbstraction; public class LanguageService { private readonly ILanguageBranchRepository _languageBranchRepository; public LanguageService(ILanguageBranchRepository languageBranchRepository) { _languageBranchRepository = languageBranchRepository; } public LanguageBranch GetByCultureName(string cultureName) { try { var culture = CultureInfo.GetCultureInfo(cultureName); var branch = _languageBranchRepository.Get(culture); Console.WriteLine($"Found branch: {branch.Culture.Name} (Active: {branch.IsActive}, Master: {branch.IsMaster})"); return branch; } catch (CultureNotFoundException) { Console.WriteLine($"Invalid culture: '{cultureName}'."); return null; } } public LanguageBranch GetById(int id) { var branch = _languageBranchRepository.Get(id); if (branch == null) { Console.WriteLine($"No language branch found for ID {id}."); return null; } Console.WriteLine($"Found branch: {branch.Culture.Name} (Active: {branch.IsActive}, Master: {branch.IsMaster})"); return branch; } }

5. About enabling and disabling language branches programmatically

Developers often ask whether they can toggle IsActive through code. In practice, language branch activation is usually treated as an administrative configuration concern, managed through CMS admin views. Changing active languages affects editorial workflows, language routing, and fallback behavior - so governance typically expects it to be controlled, reviewed, and consistent across environments.

If you truly need programmatic management, treat it like infrastructure or configuration automation: tightly restricted, audited, and validated in non-production. For most applications, the repository is used primarily for reading the language configuration.

Pro tip: If your automation needs "the list of usable languages," filter the repository results by IsActive and keep activation changes in the admin/config layer. This keeps your automation predictable and separates runtime logic from configuration management.

6. Working with localized content (where ILanguageBranchRepository fits)

Language branches define what languages exist. Localized content versions are handled through IContentLoader and IContentRepository, typically by specifying a CultureInfo or language loader options.

C#
using System.Globalization; using EPiServer; using EPiServer.Core; using EPiServer.Globalization; public class LocalizedContentExample { private readonly IContentLoader _contentLoader; public LocalizedContentExample(IContentLoader contentLoader) { _contentLoader = contentLoader; } public void LoadInSpecificLanguage(ContentReference contentLink) { var sv = CultureInfo.GetCultureInfo("sv-SE"); var swedishVersion = _contentLoader.Get<PageData>(contentLink, sv); var currentVersion = _contentLoader.Get<PageData>(contentLink, ContentLanguage.PreferredCulture); } }

Note: A typical pattern is: query language branches for what's configured, decide which cultures are valid for the current site context, then load content in the selected culture. The repository answers "what languages exist?"; IContentLoader answers "give me this content in that language."

7. Best practices for language management

  • Keep language setup consistent across environments: treat it like configuration, not random admin clicks. Include language branch state in environment parity validation.
  • Implement sensible fallback rules: define expected behavior when a translation is missing so editors and end users get predictable results.
  • Separate concerns: UI localization (resource strings) is different from content localization (language versions). Keep the two mental models distinct.
  • Be explicit in code: when language matters, pass a CultureInfo rather than relying on request defaults.
  • Audit active languages regularly: inactive branches can linger and confuse tooling and editors, especially after site restructures or language consolidations.

Conclusion

ILanguageBranchRepository is the developer entry point for understanding which language branches are configured in an Optimizely CMS 12 instance. While it is most often used for reading configuration (listing branches, checking active/master status), it plays an important supporting role in multilingual solutions: it helps you decide which cultures are valid inputs, and it enables automation to operate consistently across all configured languages.

Localized content work still happens through IContentLoader and IContentRepository by targeting the right CultureInfo.