Class TlumachMvcBuilderExtensions
- Namespace
- Tlumach.AspNetCore.Mvc
- Assembly
- Tlumach.AspNetCore.Mvc.dll
Registers Tlumach for MVC and Razor Pages: services.AddControllersWithViews() or services.AddRazorPages(), followed by these methods.
public static class TlumachMvcBuilderExtensions
- Inheritance
-
TlumachMvcBuilderExtensions
- Inherited Members
Methods
AddTlumachDisplayNames(IMvcBuilder, Action<TlumachDisplayNameOptions>?)
Gives the properties of models without [Display(Name)] or [DisplayName] a display name from Tlumach, in the culture of the request:
"DisplayNames.{container key}.{property}" (e.g. "DisplayNames.Pages.Movies.CreateModel.InputModel.Title"), then "DisplayNames.{property}"; without either, MVC shows the property name.
See TlumachDisplayNameOptions and TlumachDisplayNameKeys. Missing keys are logged at the Debug level.
public static IMvcBuilder AddTlumachDisplayNames(this IMvcBuilder builder, Action<TlumachDisplayNameOptions>? configure = null)
Parameters
builderIMvcBuilderThe MVC builder.
configureAction<TlumachDisplayNameOptions>A callback that configures the options.
Returns
- IMvcBuilder
The value of
builder.
AddTlumachModelBindingMessages(IMvcBuilder, Action<TlumachModelBindingOptions>?)
Takes the model binding messages of MVC (DefaultModelBindingMessageProvider) from Tlumach, in the culture of the request.
Keys are KeyPrefix followed by the name of the accessor without "Accessor", e.g. "ModelBinding.AttemptedValueIsInvalid".
The attempted value and the name of the field are available as {value} and {field}, which is the only way in the ARB formats (Arb, ArbNoEscaping).
With the .NET text format they are available also by position as in MVC's texts ({0}, {1}); the ARB formats reject indexed placeholders.
A message without a translation keeps MVC's English text.
public static IMvcBuilder AddTlumachModelBindingMessages(this IMvcBuilder builder, Action<TlumachModelBindingOptions>? configure = null)
Parameters
builderIMvcBuilderThe MVC builder.
configureAction<TlumachModelBindingOptions>A callback that configures the options.
Returns
- IMvcBuilder
The value of
builder.
AddTlumachViewLocalization(IMvcBuilder, Action<TlumachViewLocalizationOptions>?)
Registers the Tlumach IHtmlLocalizerFactory, IHtmlLocalizer<TResource>, and IViewLocalizer, replacing those of
AddViewLocalization regardless of the order of the calls, and adds LanguageViewLocationExpander (see ViewLocationExpanderFormat).
Call AddTlumachLocalization as well; it provides the translation managers. A repeated call (e.g. after both AddControllersWithViews() and
AddRazorPages()) configures the same options.
public static IMvcBuilder AddTlumachViewLocalization(this IMvcBuilder builder, Action<TlumachViewLocalizationOptions>? configure = null)
Parameters
builderIMvcBuilderThe MVC builder.
configureAction<TlumachViewLocalizationOptions>A callback that configures the options.
Returns
- IMvcBuilder
The value of
builder.