我想让我的 ASP.NET Core 5 Web 应用程序使用 Cookie 进行全球化。(我想)我尽一切努力进行本地化:
在启动中:
public void ConfigureServices( IServiceCollection services )
{
services.AddLocalization( options => options.ResourcesPath = "Properties" );
services.Configure<RequestLocalizationOptions>( options =>
{
options.SupportedCultures = new[]
{
new CultureInfo( "en" ),
new CultureInfo( "fr" )
};
options.SupportedUICultures = options.SupportedCultures;
options.DefaultRequestCulture = new RequestCulture( "en" );
} );
services.AddMvc()
.AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix )
.AddDataAnnotationsLocalization();
和:
public void Configure( IApplicationBuilder app, IWebHostEnvironment env )
{
...
app.UseRouting();
var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization( locOptions.Value );**
app.UseAuthentication();
...
它适用于我自己的页面(例如根据 cookie 显示 Privacy.cshtml 或 Privacy.fr.cshtml)。
我搭建了身份。翻译了所有 Areas\Identity\Pages*.cshtml,但无论 cookie 是什么,它们总是以英文显示!
为什么它适用于我自己的观点,而不适用于身份?区域有什么特别的事情要做吗?
非常感谢,