39 lines
940 B
Plaintext
39 lines
940 B
Plaintext
@* Components/CultureSwitcher.razor *@
|
|
@inject IJSRuntime JSRuntime
|
|
@inject NavigationManager Navigation
|
|
|
|
<div class="culture-switcher">
|
|
<select @bind="SelectedCulture" class="form-select">
|
|
@foreach (var culture in SupportedCultures)
|
|
{
|
|
<option value="@culture">@culture</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string[] SupportedCultures { get; set; } = new[]
|
|
{
|
|
"en",
|
|
"ar",
|
|
"es",
|
|
"de"
|
|
};
|
|
|
|
private string SelectedCulture
|
|
{
|
|
get => CultureInfo.CurrentUICulture.Name;
|
|
set
|
|
{
|
|
if (CultureInfo.CurrentUICulture.Name != value)
|
|
{
|
|
// Persist selection
|
|
JSRuntime.InvokeVoidAsync("cultureInfo.set", value);
|
|
|
|
// Reload to apply new culture
|
|
Navigation.NavigateTo(Navigation.Uri, forceLoad: true);
|
|
}
|
|
}
|
|
}
|
|
} |