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 (
localization.json) are read Storage-first from the privatelocalizationspace and merged with RESX resources at runtime. - Utility models like
TranslationEntryand view models simplify translation editors or import/export pipelines. CompositeLocalizationMetadataProviderexposes translation metadata throughIEltheonLocalizationMetadataProviderfrom Core.Abstractions so search/indexing features do not depend on Localization directly.- 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 for standalone legacy operation. With Storage registered, writes go only to the localization space while a missing Storage object may still be read from Legacy. Localizers 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. Prefer IEltheonLocalizationMetadataProvider for cross-feature consumers. Enable Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization logging to trace resource loading and culture resolution.