|
26 | 26 | using Microsoft.AspNetCore.Components.Web; |
27 | 27 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
28 | 28 | using MudBlazor.Services; |
| 29 | +using System.Globalization; |
| 30 | +using System.Reflection; |
29 | 31 | using Toolbelt.Blazor.Extensions.DependencyInjection; |
30 | 32 |
|
31 | 33 | var builder = WebAssemblyHostBuilder.CreateDefault(args); |
|
64 | 66 |
|
65 | 67 | builder.Services.AddHotKeys2(); |
66 | 68 |
|
| 69 | +// TODO: Remove this when https://github.com/dotnet/aspnetcore/issues/56824 is fixed |
| 70 | + |
| 71 | +// Get current localization culture |
| 72 | +var currentCulture = CultureInfo.DefaultThreadCurrentCulture; |
| 73 | + |
| 74 | +// Get WASM culture provider via reflection |
| 75 | +var type = Assembly.GetAssembly(typeof(WebAssemblyHost))!.GetType("Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyCultureProvider"); |
| 76 | +var instance = type |
| 77 | + !.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static) |
| 78 | + ?.GetValue(null); |
| 79 | + |
| 80 | +// Swap out the "current culture" for the UI (localization) culture |
| 81 | +CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("de-DE"); |
| 82 | +// Load the satellite assemblies |
| 83 | +await (ValueTask)instance! |
| 84 | + .GetType() |
| 85 | + .GetMethod("LoadCurrentCultureResourcesAsync", BindingFlags.Public | BindingFlags.Instance)! |
| 86 | + .Invoke(instance, [])!; |
| 87 | +// Swap the culture back |
| 88 | +CultureInfo.DefaultThreadCurrentCulture = currentCulture; |
| 89 | + |
67 | 90 | var host = builder.Build(); |
68 | 91 |
|
69 | 92 | await host.SetCultureFromConfigurationAsync(); |
|
0 commit comments