diff --git a/OliverBooth/Program.cs b/OliverBooth/Program.cs index ab3ce54..abfdf24 100644 --- a/OliverBooth/Program.cs +++ b/OliverBooth/Program.cs @@ -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); builder.Services.AddLocalization(options => options.ResourcesPath = "Resources"); -builder.Services.AddRazorPages().AddViewLocalization().AddDataAnnotationsLocalization(); - +builder.Services.AddRazorPages(); builder.Services.AddControllersWithViews(); builder.Services.AddRouting(options => options.LowercaseUrls = true); -var supportedCultures = new[] -{ - CultureInfo.GetCultureInfo("en"), - CultureInfo.GetCultureInfo("fr") -}; - -builder.Services.Configure(options => -{ - options.DefaultRequestCulture = new RequestCulture(supportedCultures[0]); - options.SupportedCultures = supportedCultures; - options.SupportedUICultures = supportedCultures; -}); - -builder.Services.Configure(options => options.ResourcesPath = "Resources"); - WebApplication app = builder.Build(); if (!app.Environment.IsDevelopment()) @@ -38,22 +16,11 @@ if (!app.Environment.IsDevelopment()) app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseRouting(); 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.UseCultureRedirect(); -app.MapControllerRoute("default", "{culture=en}/{controller=Home}/{action=Index}/{id?}"); +app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); app.MapRazorPages(); app.Run();