mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
[Blazor] Add localization.
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user