---
title: Configure a custom localization provider
slug: cms-12/docs/configuring-a-custom-localization-provider
docTags: 
createdAt: 2026-08-10T15:55:54.000Z
---

The 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.

:::hint{type="info"}
**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; 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.

```csharp
services.AddLocalizationProvider<FileXmlLocalizationProvider,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 adding a localization provider that reads embedded XML localization files from an assembly.

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

namespace CodeSamples {
  [InitializableModule]
  [ModuleDependency(typeof (FrameworkInitialization))]
  public class CustomLocalizationProviderInitialization: IConfigurableModule {
    public void ConfigureContainer(ServiceConfigurationContext context) {
      // ClassInMyAssembly can be any class in the Assembly where the resources are embedded
      context.Services.AddEmbeddedLocalization<ClassInMyAssembly>();
    }

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

### ProviderBasedLocalizationService

:::hint{type="info"}
**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.
:::
