Table of Contents

Class CookieCultureStore

Namespace
Tlumach.Blazor
Assembly
Tlumach.Blazor.dll

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

jsRuntime IJSRuntime

The JavaScript runtime.

navigationManager NavigationManager

The navigation manager, which supplies the base address of the application.

options TlumachBlazorOptions

The 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

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask<string>

The culture name, or null if nothing is stored.

SaveAsync(CultureInfo, CancellationToken)

Stores the culture.

public ValueTask SaveAsync(CultureInfo culture, CancellationToken cancellationToken = default)

Parameters

culture CultureInfo

The culture to store.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask

A task that completes when the culture is stored.