Initial commit - Common.RCL
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
@* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user