我想在我的 ASP.NET CORE MVC 应用程序中添加本地化,并将 ar-SA 作为默认本地化。我按照下面的链接配置了所有东西。我的默认语言环境是 ar-SA 并且运行良好。但是当我将语言环境更改为 en-US IsResourceNotFound 始终为真并且找不到资源
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1 https://joonasw.net/view/aspnet-core-localization-deep-dive
启动.cs
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
var supportedCultures = new[]
{
new CultureInfo("ar-SA"),
new CultureInfo("en-US"),
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("ar-SA"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
我也尝试过 .AddViewLocalization(LanguageViewLocationExpanderFormat.SubFolder) 和相同的结果