You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
883 B

using System.Globalization;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace BlazorProject.Pages;
public partial class LanguageSelector
{
private CultureInfo[] supportedLanguages = new []
{
new CultureInfo("en-US"),
new CultureInfo("fr-FR"),
new CultureInfo("ar-AE"),
};
[Inject]
private NavigationManager NavigationManager { get; set; }
[Inject]
private JSRuntime JsRuntime { get; set; }
private CultureInfo Culture
{
get => CultureInfo.CurrentCulture;
set
{
if (CultureInfo.CurrentCulture != value)
{
var js = (IJSInProcessRuntime)JsRuntime;
js.InvokeVoid("appCulture.set", value.Name);
NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
}
}
}
}