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
ItemLocalizedString- Returns the translation for
name, or the key itself when no translation is registered. ItemLocalizedString- Returns the translation for
nameformatted witharguments.
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
translationsTranslationOptionslocalizationLocalizationOptionshttpContextAccessorIHttpContextAccessor
Methods
GetAllStrings
#public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
Enumerates registered strings for the active locale, optionally including default-locale fallbacks.
Parameters
includeParentCulturesbool
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)
;
}