-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
41 lines (34 loc) · 1.42 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using BlazorDashboardApp.Client;
using DevExpress.DashboardWeb;
using Microsoft.JSInterop;
using System.Globalization;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSingleton<IDashboardLocalizationProvider>(sp => new DashboardWasmLocalizationProvider(sp));
var host = builder.Build();
var js = host.Services.GetRequiredService<IJSRuntime>();
CultureInfo culture;
string? savedCulture = null;
savedCulture = await js.InvokeAsync<string>("blazorCulture.get");
if (savedCulture != null) {
culture = new CultureInfo(savedCulture);
} else {
culture = new CultureInfo("en-US");
await js.InvokeVoidAsync("blazorCulture.set", "en-US");
}
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo uiCulture;
string? savedUICulture = null;
savedUICulture = await js.InvokeAsync<string>("blazorUICulture.get");
if (savedUICulture != null) {
uiCulture = new CultureInfo(savedUICulture);
} else {
uiCulture = new CultureInfo("en-US");
await js.InvokeVoidAsync("blazorUICulture.set", "en-US");
}
CultureInfo.DefaultThreadCurrentUICulture = uiCulture;
await builder.Build().RunAsync();