Library that provides the basic structure for managing translations from the desired source (custom providers: JSON files, InMemory database, MySQL, SQL Server, SQLite, ...) generating JSON files to be easily used in Angular (for example).
Translawesome is a .NET Standard 2.0 library.
To avoid a lot of I/O operations, a cache service has been taken in care. Obviously every project has their needs and so you (developer) have to take care of this. In the demo project (ASP.NET Core) a MemoryCache has been implemented.
The developer needs to implement his wanted translation provider (for example from JSON files or from another desired source).
After you implemented your own providers, you obviously need to register them for dependency injection.
Example:
services.AddScoped<ITranslationProvider, MyCustomTranslationProvider>();
services.AddScoped<ICacheService, MyMemoryCacheService>();
Next you added your own providers, you need to register the Translawesome service.
services.AddScoped<ITranslawesomeService, TranslawesomeService>();
You can now inject the TranslawesomeService where you need to use it.
Example:
namespace ch.igorgiovannini.Translawesome.Demo.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TranslationsController : ControllerBase
{
private readonly ITranslawesomeService _translawesomeService;
public TranslationsController(ITranslawesomeService translawesomeService) {
_translawesomeService = translawesomeService;
}
}
}
MIT