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

You have two choices for configuring localization providers.

  • Configure localization in the \<episerver.framework> section of your _web.config_. Here, you can control the behavior of all providers registered on your site and disable built-in providers.

  • Register a provider in the localization service through code during website initialization. This choice lets you place language documents in a location other than the default _lang_ folder. The following sections show how to achieve this. You might be required to grant access to the folder to the IIS application pool.


A large number of providers increases the time needed to find strings. So, for best performance, support only a few providers.

## Use the configuration option

When you add a provider that reads XML language documents through configuration, you specify a path to a physical folder. Optimizely Content Management System (CMS) does not support specifying a path to a virtual path provider (VPP). For details about the attributes available with the **<localization>** element, see the [EPiServer.Framework.Configuration.LocalizationElement](🔗) class.

The following example configuration demonstrates this option. The `addDefaultProviders` attribute is set to **false**, which means that the \_lang_folder is ignored when the site is initialized. Therefore, no language documents are included.

## Use the code-only option

Register localization providers during site initialization. The preferred way to do this is to implement the [IInitializableModule interface](🔗) and handle the registration in the Initialize method. 

The following example (using physical path) shows one way to create an `IInitializableModule` that registers a similar provider as in the configuration option above but this time through code.

Optimizely provides two convenience classes, [VirtualPathXmlLocalizationProviderInitializer](🔗) and [EmbeddedXmlLocalizationProviderInitializer](🔗), located in the [EPiServer.Framework.Localization.XmlResources](🔗) namespace. Use them when you register localization providers.

The following example (using virtual path) demonstrates using a convenience class to read XML language documents from a specified virtual path. A prerequisite for this sample is that you configure a VPP under the **<episerver>** section of _web.config_. The virtual path registered there is used as virtual path in the example. Also, this module is dependent on the Optimizely CMS InitializationModule, which is required to use a VPP, since VPPs are initialized during CMS start up.