DataWeb
Search Results for

    Show / Hide Table of Contents

    Class Localizer

    Provides localized string resources for an application.

    Inheritance
    object
    Localizer
    Implements
    IStringLocalizer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DataWeb.Localization
    Assembly: DataWeb.Core.dll
    Syntax
    public sealed class Localizer : IStringLocalizer
    Remarks

    Initializes a new instance of the Localizer class.

    Constructors

    Localizer(ILocalizationService, IHttpContextAccessor)

    Provides localized string resources for an application.

    Declaration
    public Localizer(ILocalizationService localizationService, IHttpContextAccessor httpContextAccessor)
    Parameters
    Type Name Description
    ILocalizationService localizationService

    The ILocalizationService implementation to use.

    IHttpContextAccessor httpContextAccessor

    The IHttpContextAccessor instance to use for accessing the current HTTP context.

    Remarks

    Initializes a new instance of the Localizer class.

    Properties

    Culture

    Gets or sets the culture override for this localizer instance. When set, takes precedence over the culture resolved from the HTTP context.

    Declaration
    public string Culture { get; set; }
    Property Value
    Type Description
    string

    this[string]

    Gets the localized string for the specified name.

    Declaration
    public LocalizedString this[string name] { get; }
    Parameters
    Type Name Description
    string name

    The name of the resource.

    Property Value
    Type Description
    LocalizedString

    The localized string for the specified name.

    this[string, object[]]

    Gets the localized string for the specified name and formats it with the specified arguments.

    Declaration
    public LocalizedString this[string name, params object[] arguments] { get; }
    Parameters
    Type Name Description
    string name

    The name of the resource.

    object[] arguments

    The arguments to format the string.

    Property Value
    Type Description
    LocalizedString

    The formatted localized string for the specified name.

    Methods

    GetAllStrings(bool)

    Gets all the localized strings for this localizer instance.

    Declaration
    public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
    Parameters
    Type Name Description
    bool includeParentCultures

    This parameter is not used in the current implementation.

    Returns
    Type Description
    IEnumerable<LocalizedString>

    All the localized strings for this localizer instance.

    WithCulture(string)

    Gets a new localizer instance with the specified culture.

    Declaration
    public IStringLocalizer WithCulture(string culture)
    Parameters
    Type Name Description
    string culture

    The culture override for the new localizer instance. Pass null or an empty string to use the culture from the HTTP context.

    Returns
    Type Description
    IStringLocalizer

    A new Localizer instance with Culture set to culture.

    Remarks

    This method is deprecated as of .NET 5. Use Culture directly or create a scoped instance instead.

    Implements

    IStringLocalizer
    In this article
    Back to top Generated by DocFX