Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization
Overview
The Localization feature bridges JSON-based translations, RESX resources and plugin assemblies to deliver a single IStringLocalizer surface. It allows hosts to mix static resources with runtime-managed translations and exposes factories that automatically scan plugin assemblies for their satellite resources.
Highlights
CompositeStringLocalizerFactorybuilds instances ofCompositeStringLocalizer, injecting the host assembly plus any plugin assemblies discovered by the Plugin feature.- JSON translations (e.g.,
localization.json) are merged with RESX resources at runtime so UI elements, plugins and admin tooling share the same vocabulary. - Utility models like
TranslationEntryand view models simplify translation editors or import/export pipelines. - Middleware/factories wire everything into ASP.NET Core's localization services.
Usage
builder.Services.AddSingleton<IStringLocalizerFactory>(sp =>
{
var resxFactory = new ResourceManagerStringLocalizerFactory(
sp.GetRequiredService<IOptions<LocalizationOptions>>(),
sp.GetRequiredService<ILoggerFactory>());
return new CompositeStringLocalizerFactory(
Assembly.GetExecutingAssembly(),
pluginManager.LoadedAssemblies.ToList(),
resxFactory,
Path.Combine(GlobalConfig.Instance.LocalizationPath, "localization.json"));
});
Set GlobalConfig.LocalizationPath before registering the factory to ensure the JSON store exists. Localizers obtained from this factory automatically fall back to RESX resources if a JSON entry is missing.
Diagnostics
CompositeStringLocalizer exposes helper methods such as GetAllTranslationKeys to enumerate translations for tooling. Enable Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization logging to trace resource loading and culture resolution.