@using Blazored.LocalStorage @using Microsoft.Extensions.Options @using TaikoWebUI.Settings @inject NavigationManager NavigationManager @inject IOptions Settings @inject ILocalStorageService LocalStorage @Localizer["Song Name Language"] @foreach (var culture in supportedCultures) { @culture.Value } @code { private readonly Dictionary supportedCultures = new(); protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); 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"); } var currentSongNameLanguage = await LocalStorage.GetItemAsync("songNameLanguage"); if (string.IsNullOrEmpty(currentSongNameLanguage)) { await LocalStorage.SetItemAsync("songNameLanguage", "en-US"); } } private async Task RequestCultureChange(CultureInfo newCulture) { var currentSongNameLanguage = await LocalStorage.GetItemAsync("songNameLanguage"); if (currentSongNameLanguage == newCulture.Name) { return; } await LocalStorage.SetItemAsync("songNameLanguage", newCulture.Name); NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true); } }