HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

Configure a custom localization provider

Describes how to configure the initialization of localization providers used by the default LocalizationService in Optimizely Content Management System (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.



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) { }




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.

Whatโ€™s Next