Compare commits
No commits in common. "a03c11ae9da46395a3639bd1fc11d75a424b12ab" and "57451611422e801a96a125664573a621e594f664" have entirely different histories.
a03c11ae9d
...
5745161142
|
|
@ -207,7 +207,7 @@ app.UseExceptionHandler(o => { });
|
||||||
app.UseIRacisHostStaticFileStore(env);
|
app.UseIRacisHostStaticFileStore(env);
|
||||||
|
|
||||||
//本地化
|
//本地化
|
||||||
app.UseLocalization(app.Services);
|
app.UseLocalization();
|
||||||
|
|
||||||
app.UseForwardedHeaders();
|
app.UseForwardedHeaders();
|
||||||
|
|
||||||
|
|
@ -249,7 +249,9 @@ app.MapMasaMinimalAPIs();
|
||||||
SerilogExtension.AddSerilogSetup(enviromentName, app.Services);
|
SerilogExtension.AddSerilogSetup(enviromentName, app.Services);
|
||||||
|
|
||||||
|
|
||||||
|
//设置国际化I18n
|
||||||
|
var localizer = app.Services.GetRequiredService<IStringLocalizer>();
|
||||||
|
I18n.SetLocalizer(localizer);
|
||||||
|
|
||||||
var hangfireJobService = app.Services.GetRequiredService<IIRaCISHangfireJob>();
|
var hangfireJobService = app.Services.GetRequiredService<IIRaCISHangfireJob>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
|
|
@ -12,7 +8,7 @@ namespace IRaCIS.Core.API
|
||||||
public static class LocalizationConfig
|
public static class LocalizationConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider)
|
public static void UseLocalization(this IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var supportedCultures = new List<CultureInfo>
|
var supportedCultures = new List<CultureInfo>
|
||||||
{
|
{
|
||||||
|
|
@ -34,10 +30,6 @@ namespace IRaCIS.Core.API
|
||||||
//options.RequestCultureProviders.RemoveAt(1);
|
//options.RequestCultureProviders.RemoveAt(1);
|
||||||
|
|
||||||
app.UseRequestLocalization(options);
|
app.UseRequestLocalization(options);
|
||||||
|
|
||||||
//设置国际化I18n
|
|
||||||
var localizer = serviceProvider.GetRequiredService<IStringLocalizer>();
|
|
||||||
I18n.SetLocalizer(localizer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,29 +20,12 @@ public static class I18n
|
||||||
|
|
||||||
public static string T(string key)
|
public static string T(string key)
|
||||||
{
|
{
|
||||||
if(_localizer is null)
|
return _localizer[key];
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _localizer[key];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string T(string key, params object[] arguments)
|
public static string T(string key, params object[] arguments)
|
||||||
{
|
{
|
||||||
if (_localizer is null)
|
return _localizer[key, arguments];
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _localizer[key, arguments];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue