Class CookieCultureStore
Stores the culture in the ASP.NET Core culture cookie by calling the endpoint mapped by MapTlumachCultureEndpoint through fetch,
and loads it from the lang attribute of the html element, which the server renders from the same cookie.
The store uses only built-in browser functions, so no JavaScript file is needed.
public sealed class CookieCultureStore : ITlumachCultureStore
- Inheritance
-
CookieCultureStore
- Implements
- Inherited Members
Constructors
CookieCultureStore(IJSRuntime, NavigationManager, TlumachBlazorOptions)
Initializes a new instance of the CookieCultureStore class.
public CookieCultureStore(IJSRuntime jsRuntime, NavigationManager navigationManager, TlumachBlazorOptions options)
Parameters
jsRuntimeIJSRuntimeThe JavaScript runtime.
navigationManagerNavigationManagerThe navigation manager, which supplies the base address of the application.
optionsTlumachBlazorOptionsThe options, which supply the path of the endpoint.
Methods
LoadAsync(CancellationToken)
Loads the name of the stored culture.
public ValueTask<string?> LoadAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
SaveAsync(CultureInfo, CancellationToken)
Stores the culture.
public ValueTask SaveAsync(CultureInfo culture, CancellationToken cancellationToken = default)
Parameters
cultureCultureInfoThe culture to store.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that completes when the culture is stored.