I have these files in Resources project
now the switching works, but if the language in localstorage initially is set as "fa-IR" from last session, the switching works fine between english and persian, but if the language in localstorage is set as "en-US" from last session the switching doesnt work and what ever i do, all the captions are in english and i had checked and i am sure the culture is set to right culture, please help.
i did add this in program.cs :
var host = builder.Build();
var jsRuntime = host.Services.GetRequiredService\<IJSRuntime\>();
var lang = await jsRuntime.InvokeAsync\<string\>("localStorage.getItem", "lang");
if (!string.IsNullOrEmpty(lang))
{
var culture = new CultureInfo(lang);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}
await host.RunAsync();
and this to languageService :
public async Task<bool> SetLanguageAsync(string lang)
{
SetCulture(lang);
await _jSRuntime.InvokeVoidAsync("localStorage.setItem", "lang", lang);
return true;
}
private void SetCulture(string cultureName)
{
var culture = new CultureInfo(cultureName);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}