Try our conversational search powered by Generative AI!

Class ProviderBasedLocalizationService

Provider based implementation of LocalizationService. Uses LocalizationProviders to load localized resources.

Inheritance
System.Object
ProviderBasedLocalizationService
Namespace: EPiServer.Framework.Localization
Assembly: EPiServer.Framework.dll
Version: 7.19.2
Syntax
[ServiceConfiguration(typeof(LocalizationService), Lifecycle = ServiceInstanceScope.Singleton, FactoryMember = "CreateInstance")]
[InitializableModule]
public class ProviderBasedLocalizationService : LocalizationService, IConfigurableModule, IInitializableModule
Examples

How to register a provider in web.config.

How to register a provider using a physical path in a IInitializableModule.

How to register a provider using a virtual path in a IInitializableModule.

Constructors

ProviderBasedLocalizationService()

Initializes a new instance of the ProviderBasedLocalizationService class.

Declaration
public ProviderBasedLocalizationService()

ProviderBasedLocalizationService(ResourceKeyHandler)

Initializes a new instance of the ProviderBasedLocalizationService class.

Declaration
public ProviderBasedLocalizationService(ResourceKeyHandler keyHandler)
Parameters
Type Name Description
ResourceKeyHandler keyHandler

The handler used to manipulate resource keys.

Properties

AvailableLocalizations

Gets all available localizations that the LocalizationService has knowledge of.

Declaration
public override IEnumerable<CultureInfo> AvailableLocalizations { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Globalization.CultureInfo>
Overrides

Providers

Gets a list of providers that are used by the ProviderBasedLocalizationService.

Declaration
public IList<LocalizationProvider> Providers { get; protected set; }
Property Value
Type Description
System.Collections.Generic.IList<LocalizationProvider>

The list of providers.

Remarks

Note that as the Providers are processed in prioritized order from first to last, you should insert you provider first if you want it to be called first.

Any provider added with a specified name, must have a unique name.

Methods

ConfigureContainer(ServiceConfigurationContext)

Configure the IoC container before initialization.

Declaration
public void ConfigureContainer(ServiceConfigurationContext context)
Parameters
Type Name Description
ServiceConfigurationContext context

The context on which the container can be accessed.

CreateInstance(ResourceKeyHandler, EPiServerFrameworkSection)

Creates a provider based localization service with providers from the given configuration.

Declaration
public static LocalizationService CreateInstance(ResourceKeyHandler keyHandler, EPiServerFrameworkSection configuration)
Parameters
Type Name Description
ResourceKeyHandler keyHandler

The key handler to use for the localization service.

EPiServerFrameworkSection configuration

The configuration to read.

Returns
Type Description
LocalizationService

A localization service.

GetAllStringsByCulture(String, String[], CultureInfo)

Gets all localized strings for the specified culture below the specified key.

Declaration
protected override IEnumerable<ResourceItem> GetAllStringsByCulture(string originalKey, string[] normalizedKey, CultureInfo culture)
Parameters
Type Name Description
System.String originalKey

The original key that was passed into any GetString method.

System.String[] normalizedKey

The originalKey normalized and split into an array

System.Globalization.CultureInfo culture

The requested culture for the localized strings.

Returns
Type Description
System.Collections.Generic.IEnumerable<ResourceItem>

All localized strings below the specified key.

Overrides
See Also
GetStringByCulture(System.String, System.Globalization.CultureInfo)

Initialize(InitializationEngine)

Declaration
public void Initialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

InitializeProviders(ProviderSettingsCollection)

Initializes a set of providers from the provided System.Configuration.ProviderSettingsCollection.

Declaration
public virtual void InitializeProviders(ProviderSettingsCollection settings)
Parameters
Type Name Description
System.Configuration.ProviderSettingsCollection settings

The System.Configuration.ProviderSettingsCollection to initialize the provider collection with.

LoadString(String[], String, CultureInfo)

Gets the localized string for the specified key in the specified culture.

Declaration
protected override string LoadString(string[] normalizedKey, string originalKey, CultureInfo culture)
Parameters
Type Name Description
System.String[] normalizedKey

The originalKey normalized and split into an array

System.String originalKey

The original key that was passed into any GetString method.

System.Globalization.CultureInfo culture

The requested culture for the localized string.

Returns
Type Description
System.String

A localized string or null if no resource is found for the given key and culture.

Overrides
See Also
GetStringByCulture(System.String, System.Globalization.CultureInfo)

Preload(String[])

Declaration
public void Preload(string[] parameters)
Parameters
Type Name Description
System.String[] parameters

Uninitialize(InitializationEngine)

Declaration
public void Uninitialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

Implements

Extension Methods