This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

PenningtonStringLocalizer Pennington.Localization

An IStringLocalizer backed by TranslationOptions. Reads the locale that LocaleDetectionMiddleware already detected for the request from the scoped LocaleContext, and looks up translations with fallback to the default locale, then to the key itself.

Properties

Item LocalizedString
Returns the translation for name, or the key itself when no translation is registered.
Item LocalizedString
Returns the translation for name formatted with arguments.

Constructors

PenningtonStringLocalizer

#
public PenningtonStringLocalizer(TranslationOptions translations, LocalizationOptions localization, IHttpContextAccessor httpContextAccessor = null)

Creates the localizer. httpContextAccessor supplies the per-request LocaleContext; when absent (outside a request) the default locale is used.

Parameters

translations TranslationOptions
localization LocalizationOptions
httpContextAccessor IHttpContextAccessor

Methods

GetAllStrings

#
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)

Enumerates registered strings for the active locale, optionally including default-locale fallbacks.

Parameters

includeParentCultures bool

Returns

IEnumerable<LocalizedString>

Pennington.Localization.PenningtonStringLocalizer

namespace Pennington.Localization;

/// An IStringLocalizer backed by TranslationOptions. Reads the locale that LocaleDetectionMiddleware already detected for the request from the scoped LocaleContext, and looks up translations with fallback to the default locale, then to the key itself.
public class PenningtonStringLocalizer
{
    /// Enumerates registered strings for the active locale, optionally including default-locale fallbacks.
    
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
; /// Returns the translation for name, or the key itself when no translation is registered.
public LocalizedString Item { get; }
/// Returns the translation for name formatted with arguments.
public LocalizedString Item { get; }
/// Creates the localizer. httpContextAccessor supplies the per-request LocaleContext; when absent (outside a request) the default locale is used.
public PenningtonStringLocalizer(TranslationOptions translations, LocalizationOptions localization, IHttpContextAccessor httpContextAccessor = null)
; }