I have been following the instructions on this page to setup Localization:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization
However, fo
I had this same problem around a week ago. I solved it with this:
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[] { new CultureInfo("en"), new CultureInfo("es") };
options.DefaultRequestCulture = new RequestCulture(culture: "en", uiCulture: "en");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(locOptions.Value);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
One more comment, though. In ASP.NET Core, the default culture resource should not be created, only specific ones:
So, given
Views/Shared/Layout.cshtml
Only create
Resources/Views/Shared/Layout.es-MX.resx
Do notice, also, that you are limiting Spanish to Mexican by this, so you should either have a es
fallback, or add both es
and es-MX
.