I am making an ASP.NET Core 1.1 application and trying to set up localization.
When I do on my ValuesControllerimplementation IStringLocalizer, it works fine and localizes my resource file.
public ValuesController(IStringLocalizer<ValuesController> localizer, IService<BaseEntity> service)
{
_localizer = localizer;
_service = service;
}
In the above code, find the resources in the Resources / Controllers / Values section of Controller.en-US.resx.
But, when I try to enter IStringLocalizerinto a shared service, it cannot find the resource file.
public class Service<T> : IService<T>
where T : BaseEntity
{
#region Properties
protected IRepository Repository { get; set; }
protected IUnitOfWorkFactory UnitOfWorkFactory { get; set; }
private readonly ILogger _logger;
private readonly IStringLocalizer _localizer;
#endregion
#region Ctor
public Service(IRepository repository, IUnitOfWorkFactory unitOfWorkFactory,
ILogger<Service<T>> logger, IStringLocalizer<Service<T>> localizer)
{
Repository = repository;
UnitOfWorkFactory = unitOfWorkFactory;
_logger = logger;
_localizer = localizer;
}
}
In the above code, my resource was not found in the section "Resources / Services / Base / Service .en-US.resx"
Any idea on how to do this?
--- EDIT
MyControl.Api (Startup.cs)
namespace MyControl.Api
services.AddLocalization(options => options.ResourcesPath = "Resources");
This line is located inside "MyControl.Api", which is located in the namespace "MyControl.Api".
"/"
"MyControl.Services"
( )
"//Base"
- "MyControl.Services.Services.Base"