Hello,
After upgrate to Net Core 2.0 Localization in View is not Working, but In Controller works .
I tried to create a default project in Net Core 2.0 and is not working too .
ConfigureServices
- services.AddLocalization(options => options.ResourcesPath = "Resources");
- services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
- In Folder Resource I have SharedResource.fr-FR.resx
- Shared Resource Class :
namespace PL
{
public class SharedResource
{
}
}
- @inject Microsoft.Extensions.Localization.IStringLocalizer<PL.SharedResource> SharedResource
- @SharedLocalizer["Add"]
public IStringLocalizer<SharedResource> _SharedResource;
public HomeController(IStringLocalizer<SharedResource> sharedResource)
{
CultureInfo uiCulture = new CultureInfo("fr-FR");
CultureInfo.CurrentUICulture = uiCulture;
CultureInfo.CurrentCulture = new CultureInfo("fr-FR");
_SharedResource = sharedResource;
}
But I I test with a ViewData from controller is working
ViewData["Message"] = _SharedResource["Add"];
Thank's