I set the localization as described in Microsoft's blog, but the default language is always English. This is how my Startup.cs looks like with regards to the localization.
CultureInfo[] supportedCultures = new[]
{
new CultureInfo("ar"),
new CultureInfo("en")
};
In ConfigureServices method:
services.Configure<RequestLocalizationOptions>(options =>
{
options.DefaultRequestCulture = new RequestCulture("ar", "ar");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
services.AddLocalization(options =>
{
options.ResourcesPath = "Resources";
});
services.AddMvc()
.AddViewLocalization()
.AddDataAnnotationsLocalization();
In Configure method:
app.UseRequestLocalization(new RequestLocalizationOptions()
{
DefaultRequestCulture = new RequestCulture("ar"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
Thanks :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…