Area: Optimizely CMS
Applies to versions: 12 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Configuring a localization provider

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

This topic explains how to configure the initialization of localization providers used by the default LocalizationService in Optimizely CMS. There way to configure localization is through LocalizationOptions or through extension methods AddLocalization or AddEmbeddedLocalization to IServiceCollection during website initialization.

The following sections show how to achieve this.

Note: A large number of providers increases the time needed to find strings. For best performance, keep the number of localization providers to a minimal.


You can register localization providers during the configuration phase of the site initialization from the Startup class using IServiceCollection. Or, you can create an initialization module that implements the IConfigurableModule interface and handle the registration in the ConfigureContainer method; either by configuring the LocalizationOptions class or through the AddLocalizationProvider extension method available on the IServiceCollection interface.

The following example shows how to register a localization provider from method ConfigureServices in the Startup class.

  NameValueCollection>(o =>
      o[FileXmlLocalizationProvider.PhysicalPathKey] = @"c:\temp\resourceFolder";

Optimizely also includes a provider for reading localization resources from embedded XML files, called EPiServer.Framework.Localization.XmlResources.EmbeddedXmlLocalizationProviderInitializer.

The following example demonstrates how to add a localization provider that reads all embedded XML localization files from an assembly.

using System;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Framework.Localization;

namespace CodeSamples
    public class CustomLocalizationProviderInitialization : IConfigurableModule
        public void ConfigureContainer(ServiceConfigurationContext context)
            // ClassInMyAssembly can be any class in the Assembly where the resources are embedded

        public void Initialize(InitializationEngine context) { }
        public void Uninitialize(InitializationEngine context) { }


Note: You can also directly modify LocalizationService through the API of the ProviderBasedLocalizationService, but you should use another method because this API is likely to be deprecated in a future version.

Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading