I\'ve been trying to implement localization for my asp .NET Core 1.0 RTM web app following microsofts documentation and I just can not get it to work. The problem I\'m havin
Edit on @Siim Haas.
It's works good.
In my case: I using the LanguageViewLocationExpanderFormat.SubFolder
At ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; });
services.AddMvc()
.AddViewLocalization(
Microsoft.AspNetCore.Mvc.Razor.LanguageViewLocationExpanderFormat.SubFolder,
opts => { opts.ResourcesPath = "Resources"; }
)
.AddDataAnnotationsLocalization();
services.Configure(opts =>
{
var supportedCultures = new[]
{
new CultureInfo("en-AU"),
new CultureInfo("en-GB"),
new CultureInfo("en-US"),
new CultureInfo("en"),
new CultureInfo("zh-cn"),
new CultureInfo("zh"),
};
opts.DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("en-US");
opts.SupportedCultures = supportedCultures;
opts.SupportedUICultures = supportedCultures;
});
}
At Configure (IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseRequestLocalization();
app.UseMvc(routes =>
{
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}");
});
}
My Resources stucts Like:
{Your Project}/Resources/Views/{your controller}/ViewName.en-us.resx