实现多语言切换
This commit is contained in:
@@ -26,8 +26,14 @@ builder.Services.AddScoped<IconsExtension>();
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||||
|
||||
|
||||
// ע<><D7A2>IStringLocalizer
|
||||
builder.Services.AddTransient(typeof(IStringLocalizer<>), typeof(StringLocalizer<>));
|
||||
// ע<><D7A2> LocalizationProvider (<28><><EFBFBD><EFBFBD> WASM)
|
||||
// Use Scoped lifetime because LocalizationProvider depends on IJSRuntime (scoped) and IHttpClient etc.
|
||||
builder.Services.AddScoped<ILocalizationProvider, LocalizationProvider>();
|
||||
// ע<><D7A2> ILocalizationService <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> Culture <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䴫<EFBFBD><E4B4AB>
|
||||
builder.Services.AddScoped<ILocalizationService, LocalizationService>();
|
||||
|
||||
// ע<><D7A2> IStringLocalizer<T> ʵ<><CAB5>
|
||||
builder.Services.AddTransient(typeof(IStringLocalizer<>), typeof(JsonStringLocalizer<>));
|
||||
// <20><><EFBFBD>ӱ<EFBFBD><D3B1>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
builder.Services.AddLocalization();
|
||||
|
||||
@@ -64,4 +70,6 @@ builder.Services.AddScoped<HttpService>(sp =>
|
||||
builder.Services.AddAntDesign();
|
||||
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
var host = builder.Build();
|
||||
|
||||
await host.RunAsync();
|
||||
|
||||
Reference in New Issue
Block a user