[Blazor] Add localization.

This commit is contained in:
2025-07-27 17:19:25 +01:00
parent 396ee08030
commit a551e2474d
12 changed files with 568 additions and 73 deletions

View File

@@ -1,5 +1,4 @@
using System.Diagnostics;
using Microsoft.EntityFrameworkCore;
using Microsoft.FluentUI.AspNetCore.Components;
using RomRepoMgr.Blazor;
using RomRepoMgr.Blazor.Components;
@@ -57,6 +56,9 @@ builder.Host.UseSerilog(); // ✅ Plug Serilog into the host
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
builder.Services.AddFluentUIComponents();
// Localization
builder.Services.AddLocalization();
Log.Debug("Creating database context...");
builder.Services.AddDbContextFactory<Context>(options =>
@@ -100,6 +102,18 @@ app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
// Localization
string[] supportedCultures = new[]
{
"en", "es"
};
RequestLocalizationOptions localizationOptions = new RequestLocalizationOptions().SetDefaultCulture("en")
.AddSupportedCultures(supportedCultures)
.AddSupportedUICultures(supportedCultures);
app.UseRequestLocalization(localizationOptions);
Stopwatch stopwatch = new();
using(IServiceScope scope = app.Services.CreateScope())