mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-25 03:06:36 +08:00
框架重构
清除多余的业务
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Language;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static class LocalizerExtend
|
||||
{
|
||||
public static IServiceCollection AddLocalizerService(this IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddLocalization();
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void UseLocalizerService(this IApplicationBuilder app)
|
||||
{
|
||||
Result._local = app.ApplicationServices.GetService<IStringLocalizer<LocalLanguage>>();
|
||||
|
||||
var support = new[] { "zh", "en" };
|
||||
var local = new RequestLocalizationOptions().SetDefaultCulture(support[0])
|
||||
.AddSupportedCultures(support)
|
||||
.AddSupportedUICultures(support);
|
||||
app.UseRequestLocalization(local);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user