修改国际化配置提前
This commit is contained in:
@@ -207,7 +207,7 @@ app.UseExceptionHandler(o => { });
|
||||
app.UseIRacisHostStaticFileStore(env);
|
||||
|
||||
//本地化
|
||||
app.UseLocalization();
|
||||
app.UseLocalization(app.Services);
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
@@ -249,9 +249,7 @@ app.MapMasaMinimalAPIs();
|
||||
SerilogExtension.AddSerilogSetup(enviromentName, app.Services);
|
||||
|
||||
|
||||
//设置国际化I18n
|
||||
var localizer = app.Services.GetRequiredService<IStringLocalizer>();
|
||||
I18n.SetLocalizer(localizer);
|
||||
|
||||
|
||||
var hangfireJobService = app.Services.GetRequiredService<IIRaCISHangfireJob>();
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
@@ -8,7 +12,7 @@ namespace IRaCIS.Core.API
|
||||
public static class LocalizationConfig
|
||||
{
|
||||
|
||||
public static void UseLocalization(this IApplicationBuilder app)
|
||||
public static void UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider)
|
||||
{
|
||||
var supportedCultures = new List<CultureInfo>
|
||||
{
|
||||
@@ -30,6 +34,10 @@ namespace IRaCIS.Core.API
|
||||
//options.RequestCultureProviders.RemoveAt(1);
|
||||
|
||||
app.UseRequestLocalization(options);
|
||||
|
||||
//设置国际化I18n
|
||||
var localizer = serviceProvider.GetRequiredService<IStringLocalizer>();
|
||||
I18n.SetLocalizer(localizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user