Table of Contents

Class TlumachHtmlLocalizerFactory

Namespace
Tlumach.AspNetCore.Mvc
Assembly
Tlumach.AspNetCore.Mvc.dll

Creates the Tlumach HTML localizers. The translation manager of a localizer is found as for TlumachStringLocalizerFactory: the options for the context (the full name of the type, or the location and the base name), then the default options, then the static TranslationManager property of a class created by Tlumach Generator.

Managers created from options are cached by what the options describe (the TranslationManager instance, the Configuration instance, or the DefaultFile with its assembly and locale, together with the text processing mode), not by the options instance, so the transient localizers do not load translations again even when the settings provider returns new options objects. The options are still requested for every localizer, so a provider can switch a context to another manager at runtime.

public sealed class TlumachHtmlLocalizerFactory : IHtmlLocalizerFactory
Inheritance
TlumachHtmlLocalizerFactory
Implements
Inherited Members

Constructors

TlumachHtmlLocalizerFactory(ITlumachSettingsProvider, HtmlEncoder, TlumachViewLocalizationOptions)

Initializes a new instance of the TlumachHtmlLocalizerFactory class.

public TlumachHtmlLocalizerFactory(ITlumachSettingsProvider settingsProvider, HtmlEncoder encoder, TlumachViewLocalizationOptions options)

Parameters

settingsProvider ITlumachSettingsProvider

The options registered by AddTlumachLocalization.

encoder HtmlEncoder

The encoder of placeholder values.

options TlumachViewLocalizationOptions

The options of the view localization.

Methods

Create(string, string)

Creates an HTML localizer from the options for the context or, when they set none of TranslationManager, Configuration, and DefaultFile, from the default file named baseName, embedded into resources of the assembly that location names or, when location is empty or is not the name of a loadable assembly, of the assembly that is calling this method. This is the rule of Create(string, string).

As for the HTML localizer factory of MVC, location is the name of the assembly that holds the resources (MVC's ViewLocalizer passes the name of the application), so the file is found also when framework code calls this method on behalf of the application. A location that is not an assembly name does not cause an error, because it may be meant only as a part of the options context.

A DefaultFile of the options is loaded from Assembly or, when that is not set, from the entry assembly; location does not change that.

public IHtmlLocalizer Create(string baseName, string location)

Parameters

baseName string

The name of the default file.

location string

The name (simple or full) of the assembly whose resources contain the default file named baseName, or an empty string to use the calling assembly. When not empty, it is also a part of the options context, location.baseName.

Returns

IHtmlLocalizer

The HTML localizer.

Exceptions

ArgumentNullException

baseName is null.

Create(Type)

Creates an IHtmlLocalizer using the Assembly and FullName of the specified Type.

public IHtmlLocalizer Create(Type resourceSource)

Parameters

resourceSource Type

The Type.

Returns

IHtmlLocalizer

The IHtmlLocalizer.