@using System.Globalization; @using Microsoft.Extensions.Options @using TaikoWebUI.Settings @inject NavigationManager NavigationManager @inject IJSRuntime JSRuntime @inject IOptions Settings @foreach (var culture in SupportedCultures) { @culture.Value } @code { public Dictionary SupportedCultures = new(); protected override void OnInitialized() { base.OnInitialized(); foreach (var language in Settings.Value.SupportedLanguages) { SupportedCultures.Add(new CultureInfo(language.CultureCode), language.DisplayName); } if (SupportedCultures.Count == 0) { SupportedCultures.Add(new CultureInfo("en-US"), "English"); } } private void RequestCultureChange(CultureInfo newCulture) { if (Equals(CultureInfo.CurrentCulture, newCulture)) { return; } var js = (IJSInProcessRuntime)JSRuntime; js.InvokeVoid("blazorCulture.set", newCulture.Name); NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true); } }