Appveyor | Travis |
---|---|
This package is an Implementation of IStringLocalizer
for asp.net core. It uses json files to store localized strings plus the IDistributedCache
implementation in order to cache out the localized strings. The flow is pretty simple,
- whenever a localized string is requested it is firstly checked in the
IDistributedCache
- If the value for the key is not found in the cache, it is then read from the json file for the respective
CultureInfo
- When the value is retrieved from json file and it is valid, it's stored in the cache before returning it to the caller.
In this way the localized strings are cached only when requested and are physically stored in json files only.
In Startup.cs make sure to add the localizer factory and the IStringLocalizer service with it's factory to create objects.
services.Configure<JsonLocalizerOptions>(Configuration.GetSection(nameof(JsonLocalizerOptions)));
services.AddSingleton<IStringLocalizerFactory, JsonStringLocalizerFactory>();
services.AddTransient(serviceProvider =>
{
var factory = serviceProvider.GetRequiredService<IStringLocalizerFactory>();
return factory.Create(null);
});
Checkout package description and installation instructions on nuget.org