Namespace Tlumach.Blazor
Classes
- CookieCultureStore
Stores the culture in the ASP.NET Core culture cookie by calling the endpoint mapped by
MapTlumachCultureEndpointthroughfetch, and loads it from thelangattribute of thehtmlelement, which the server renders from the same cookie.The store uses only built-in browser functions, so no JavaScript file is needed.
- LocalStorageCultureStore
Stores the culture in the local storage of the browser. Used by standalone Blazor WebAssembly and Blazor Hybrid applications.
- TlumachBlazorOptions
The options of the Blazor integration of Tlumach, configured in AddTlumachBlazor(IServiceCollection, Action<TlumachBlazorOptions>?).
- TlumachBlazorServiceCollectionExtensions
Registers the Blazor integration of Tlumach.
- TlumachBlazorServiceProviderExtensions
Startup helpers for Blazor WebAssembly applications.
- TlumachComponentBase
An optional base class for components that use translations in code or in attributes, where TlumachText cannot be placed.
The component re-renders when the user switches the language, because it takes the cascading TlumachCulture value. The class subscribes to no events, so it needs no disposal.
- TlumachCulture
An immutable snapshot of the culture of one user, cascaded to components by TlumachCultureState.
A component that declares a cascading parameter of this type is re-rendered when the user switches the language. The methods of this class retrieve texts for Culture explicitly, which is what keeps the users of a Blazor Server application apart.
- TlumachCultureSelector
Lets the user choose one of SupportedCultures.
In an interactive component, it is a
selectelement that switches the language when the selection changes. In static server-side rendering, it is a form that sends the choice to the culture endpoint (MapTlumachCultureEndpoint), which stores it in a cookie and reloads the page.
- TlumachCultureState
Holds the culture of one user and switches it.
The service is scoped: Blazor Server creates one per circuit (and one per prerendering request), so the users of one server do not share the culture; Blazor WebAssembly and Blazor Hybrid effectively have one per application.
Components re-render after a switch through the cascading TlumachCulture value; other code can subscribe to CultureChanged.
- TlumachText
Renders the text of a translation unit or of a key in the culture of the user and re-renders when the user switches the language.
The text is HTML-encoded like any other Razor output. If the translation manager encodes values itself (WebEncodeValues), the already encoded text is not encoded again. Set AsMarkup only for translations that contain trusted HTML; string placeholder values are HTML-encoded in that mode.
Interfaces
- ITlumachCultureStore
Stores the culture that the user has chosen so that the next visit or the next circuit starts with it.
Register an own implementation before calling AddTlumachBlazor(IServiceCollection, Action<TlumachBlazorOptions>?) to replace the built-in stores.
Enums
- TlumachCulturePersistence
Specifies where TlumachCultureState stores the culture that the user has chosen.