Hi,
I have a Blazor WASM application. The app supports two cultures (pl-PL, en-US).
I would like that when I launch the application until the culture cookie is created, the default culture is always pl-PL. Currently it is always en-US culture. Is it possible to do this without creating a custom .js method along the lines of Radzen.getCulture? I also wouldn't want to reload the application using CultureController.
On the server side, I have the following configuration:
var supportedCultures = CultureService.Cultures;
var localizationOptions = new RequestLocalizationOptions()
.AddSupportedCultures(supportedCultures)
.AddSupportedUICultures(supportedCultures)
.SetDefaultCulture("pl-PL");
(...)
public static readonly string[] Cultures = new[]
{
"pl-PL",
"en-US"
};
On the client side, I have the following configuration:
var jsRuntime = host.Services.GetRequiredService<IJSRuntime>();
var culture = await jsRuntime.InvokeAsync<string>("Radzen.getCulture");
if (!string.IsNullOrEmpty(culture))
{
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture);
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(culture);
}
I see that the Radzen.getCulture method return en-US if there is no culture cookie:
getCulture: function () {
var cultureCookie = Radzen.getCookie('.AspNetCore.Culture');
var uiCulture = cultureCookie
? cultureCookie.split('|').pop().split('=').pop()
: null;
return uiCulture || 'en-US';