fix: amend 75eed18bc8
This commit is contained in:
parent
75eed18bc8
commit
b2ada7d720
@ -1,32 +1,10 @@
|
|||||||
using System.Globalization;
|
|
||||||
using Microsoft.AspNetCore.Localization;
|
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using OliverBooth;
|
|
||||||
using OliverBooth.Middleware;
|
|
||||||
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
|
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
|
||||||
builder.Services.AddRazorPages().AddViewLocalization().AddDataAnnotationsLocalization();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
builder.Services.AddRouting(options => options.LowercaseUrls = true);
|
builder.Services.AddRouting(options => options.LowercaseUrls = true);
|
||||||
|
|
||||||
var supportedCultures = new[]
|
|
||||||
{
|
|
||||||
CultureInfo.GetCultureInfo("en"),
|
|
||||||
CultureInfo.GetCultureInfo("fr")
|
|
||||||
};
|
|
||||||
|
|
||||||
builder.Services.Configure<RequestLocalizationOptions>(options =>
|
|
||||||
{
|
|
||||||
options.DefaultRequestCulture = new RequestCulture(supportedCultures[0]);
|
|
||||||
options.SupportedCultures = supportedCultures;
|
|
||||||
options.SupportedUICultures = supportedCultures;
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.Configure<LocalizationOptions>(options => options.ResourcesPath = "Resources");
|
|
||||||
|
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
@ -38,22 +16,11 @@ if (!app.Environment.IsDevelopment())
|
|||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.UseRequestLocalization(options =>
|
|
||||||
{
|
|
||||||
options.ApplyCurrentCultureToResponseHeaders = true;
|
|
||||||
options.DefaultRequestCulture = new RequestCulture(supportedCultures[0]);
|
|
||||||
options.SupportedCultures = supportedCultures;
|
|
||||||
options.SupportedUICultures = supportedCultures;
|
|
||||||
options.RequestCultureProviders.Insert(0, new RouteCultureProvider(supportedCultures[0]));
|
|
||||||
});
|
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.UseCultureRedirect();
|
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
||||||
app.MapControllerRoute("default", "{culture=en}/{controller=Home}/{action=Index}/{id?}");
|
|
||||||
app.MapRazorPages();
|
app.MapRazorPages();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
Loading…
Reference in New Issue
Block a user