NuGet ยท nuget

Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization

Core Featur for Localization for Eltheon Framework

Install

Install-Kommandos

dotnet add package Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization --version 0.9.0.11
<PackageReference Include="Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization" Version="0.9.0.11" />
paket add Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization --version 0.9.0.11
Install-Package Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Localization -Version 0.9.0.11

README

Vorschau

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

  • CompositeStringLocalizerFactory builds instances of CompositeStringLocalizer, 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 TranslationEntry and 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.