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
});
DefaultRequestCulture
butDefaultRequestCulture
is used if none of the providers(QueryStringRequestCultureProvider
,CookieRequestCultureProvider
,AcceptLanguageHeaderRequestCultureProvider
) can determine the request culture. My guess is that your browser is set to "english". – FuelQueryStringRequestCultureProvider
fromRequestCultureProviders
– Fuelde-DE
" or "en-US
" instead of e.g. "de
" or "en
" for the supported cultures and RequestCulture. After the change to e.g. "de
" or "en
", the system worked perfectly, even if my browser sent e.g. a "de-DE
", it was correctly matched with the server-side provided "de
" culture/language. – Biauriculate