Update request localization
This commit is contained in:
@@ -3,7 +3,9 @@ using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Vegasco.Server.Api.Authentication;
|
||||
using Vegasco.Server.Api.Common;
|
||||
using Vegasco.Server.Api.Persistence;
|
||||
@@ -29,11 +31,11 @@ public static class DependencyInjectionExtensions
|
||||
|
||||
private static IServiceCollection AddMiscellaneousServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(sp =>
|
||||
services.AddSingleton(() =>
|
||||
{
|
||||
var assemblyName = Assembly.GetExecutingAssembly()
|
||||
.GetName()
|
||||
.Name ?? "Vegasco.Server.Api";
|
||||
string assemblyName = Assembly.GetExecutingAssembly()
|
||||
.GetName()
|
||||
.Name ?? "Vegasco.Server.Api";
|
||||
return new ActivitySource(assemblyName);
|
||||
});
|
||||
|
||||
@@ -50,6 +52,21 @@ public static class DependencyInjectionExtensions
|
||||
|
||||
services.AddHostedService<ApplyMigrationsService>();
|
||||
|
||||
services.AddRequestLocalization(o =>
|
||||
{
|
||||
string[] cultures =
|
||||
[
|
||||
"en-US",
|
||||
"en",
|
||||
"de-DE",
|
||||
"de"
|
||||
];
|
||||
|
||||
o.SetDefaultCulture(cultures[0])
|
||||
.AddSupportedCultures(cultures)
|
||||
.AddSupportedUICultures(cultures);
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +23,7 @@ internal static class StartupExtensions
|
||||
{
|
||||
app.UseRequestLocalization(o =>
|
||||
{
|
||||
o.SupportedCultures =
|
||||
[
|
||||
new CultureInfo("en")
|
||||
];
|
||||
|
||||
o.SupportedUICultures = o.SupportedCultures;
|
||||
|
||||
CultureInfo defaultCulture = o.SupportedCultures[0];
|
||||
o.DefaultRequestCulture = new RequestCulture(defaultCulture);
|
||||
o.ApplyCurrentCultureToResponseHeaders = true;
|
||||
});
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
Reference in New Issue
Block a user