Table of Contents

Namespace Tlumach.AspNetCore.Mvc

Classes

TlumachCultureSelectorTagHelper

Lets the user choose one of SupportedCultures: a form that sends the choice to the culture endpoint (MapTlumachCultureEndpoint), which stores it in the culture cookie and returns to the current page. No script is used; add one that submits the form on change if the button is not wanted. Nothing is rendered when no cultures are supported.

TlumachDisplayNameKeys

Forms the keys of display names. Keys use dots only: nested types are separated by dots, and the arity of generic types ("`1") and type arguments are dropped.

TlumachDisplayNameOptions

Options of AddTlumachDisplayNames(IMvcBuilder, Action<TlumachDisplayNameOptions>?).

TlumachHtmlHelperExtensions

Renders translation units in views without @Html.Raw: @Html.Tlumach(Strings.Home.Intro, Model.Name).

The translation is trusted HTML; values are HTML-encoded, except IHtmlContent values. WebEncodeValues does not affect the output. Values cached on the unit or supplied by OnPlaceholderValueNeeded are used for placeholders without a value; they are shared by all requests.

TlumachHtmlLocalizer

An IHtmlLocalizer backed by a Tlumach translation manager.

The translation is trusted HTML and is not encoded; the values of its placeholders are HTML-encoded, except IHtmlContent values, which are inserted as they are. All Tlumach placeholders are supported: {0}, {name}, ICU plural and select, dates, and numbers. A single IReadOnlyDictionary<TKey, TValue> argument supplies named values. WebEncodeValues does not affect the HTML.

The braces of the rendered HTML are doubled in Value, which MVC treats as a format string; WriteTo(TextWriter, HtmlEncoder) writes the HTML exactly.

TlumachHtmlLocalizerFactory

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.

TlumachHtmlLocalizer<TResource>

An IHtmlLocalizer<TResource> backed by Tlumach; see TlumachHtmlLocalizer.

TlumachKeyTagHelper

Replaces the content of an element with a translation: <h1 tlumach-key="Title"></h1> or <p tlumach-unit="Strings.Home.Intro" tlumach-arg-name="@Model.Name"></p>.

A key is looked up in three steps: with the prefix of the file that is being executed (e.g. "Views.Home.Index."), then with the prefix of the main view, then without a prefix (the shared key). The second step exists because a @section of a view runs while the layout executes, so the executing file is the layout there; thanks to it, a tag helper in a section finds the keys of its own view. The side effect is that a tag helper in a layout finds the keys of the current view, if the layout has no such key. TlumachViewLocalizer does not do that: it uses the file that is being executed and the shared key.

The translation is trusted HTML; values are HTML-encoded, except IHtmlContent values. Values of tlumach-arg-* and tlumach-args are C# expressions (@Model.Name, @("text")). tlumach-culture is the name of a culture; an invalid name throws CultureNotFoundException.

TlumachModelBindingOptions

Options of AddTlumachModelBindingMessages(IMvcBuilder, Action<TlumachModelBindingOptions>?).

TlumachMvcBuilderExtensions

Registers Tlumach for MVC and Razor Pages: services.AddControllersWithViews() or services.AddRazorPages(), followed by these methods.

TlumachTextTagHelper

Renders a translation without a wrapping element: <tlumach-text key="Welcome" />. Attributes: key, unit, args, arg-*, culture; the rules are those of TlumachKeyTagHelper: a key is looked up with the prefix of the file that is being executed, then with the prefix of the main view (a @section runs in the context of the layout), then without a prefix. An invalid culture name throws CultureNotFoundException.

TlumachViewLocalizationOptions

Options of the Tlumach view localization, set with AddTlumachViewLocalization(IMvcBuilder, Action<TlumachViewLocalizationOptions>?).

The options are read when a view is first localized; change them only while the application starts.

TlumachViewLocalizer

An IViewLocalizer backed by Tlumach. A key is looked up with the prefix of the view (ViewKeyPrefix, e.g. "Views.Home.Index.Title") and then without it ("Title"), so that views can share texts. Partial views and layouts use their own prefix. The encoding rules are those of TlumachHtmlLocalizer.

Enums

TlumachDisplayNameKeyStyle

How the key of the container type of a property is formed; see GetContainerKey(Type, TlumachDisplayNameKeyStyle, string?).