Class TlumachAspNetCoreExtensions
- Namespace
- Tlumach.AspNetCore
- Assembly
- Tlumach.AspNetCore.dll
Connects the culture chosen by the user with the request localization of ASP.NET Core (Blazor, MVC, Razor Pages, or minimal APIs).
public static class TlumachAspNetCoreExtensions
- Inheritance
-
TlumachAspNetCoreExtensions
- Inherited Members
Methods
MapTlumachCultureEndpoint(IEndpointRouteBuilder, string?)
Maps the endpoint that stores the chosen culture in the ASP.NET Core culture cookie.
POST {pattern}?culture=de-DE sets the cookie and returns 204; it is called by CookieCultureStore of Tlumach.Blazor.
GET {pattern}?culture=de-DE&redirectUri=/page sets the cookie and redirects to the local URI; it is used by the form of the culture selectors of Tlumach.Blazor and Tlumach.AspNetCore.Mvc
in static server-side rendering. An unsupported culture yields 400.
The culture is resolved with FindSupportedCulture(string): when SupportedCultures is empty, only the names of predefined cultures are accepted, so that requests cannot make the server cache cultures without bound.
public static IEndpointConventionBuilder MapTlumachCultureEndpoint(this IEndpointRouteBuilder endpoints, string? pattern = null)
Parameters
endpointsIEndpointRouteBuilderThe endpoint route builder.
patternstringThe route pattern. When null, CultureEndpoint is used.
Returns
- IEndpointConventionBuilder
A builder for further configuration of both endpoints.
UseTlumachRequestLocalization(IApplicationBuilder)
Adds the request localization middleware configured from TlumachCultureOptions: the supported cultures, the default culture,
and the culture cookie as the first source of the culture. Call AddTlumachCultures or AddTlumachBlazor first.
public static IApplicationBuilder UseTlumachRequestLocalization(this IApplicationBuilder app)
Parameters
appIApplicationBuilderThe application.
Returns
- IApplicationBuilder
The value of
app.