GenericLocalizeTagHelper Class

Summary

Adds support to localize the inner text for a tag, when one of the following attributes have been added: localize, localize-html or localize-type.
Namespace
Localization.AspNetCore.TagHelpers
Base Types
  • TagHelper
Derived Types
graph BT Type-->Base0["TagHelper"] Type["GenericLocalizeTagHelper"] class Type type-node Derived0["LocalizeTagHelper"]-->Type click Derived0 "/Localization.AspNetCore.TagHelpers/api/Localization.AspNetCore.TagHelpers/LocalizeTagHelper"

Syntax

[HtmlTargetElement(Attributes = "localize")]
public class GenericLocalizeTagHelper : TagHelper

Examples

<span localize="">
To text to localize goes here
</span>

Attributes

Type Description
HtmlTargetElement

Constructors

Properties

Name Value Summary
IsHtml bool
Gets or sets a value indicating whether the inner text should be treated as HTML (no encoding).
Localizer IHtmlLocalizer
Gets or sets the localizer to use when resolving the specified strings.
Name string
Gets or sets the name to optionally override the name/path of the resource file. If the name is empty it resolves to the current path and name of the view. i.e the view located at "~/Views/Home/About.cshtml" passes the following name to the html localizer as Views/Home/About.
NewLineHandling NewLineHandling
Gets or sets the new line handing method.
SupportsParameters bool
Gets a value indicating whether this localizer tag helper supports parameters.
TrimEachLine bool
Gets or sets a value indicating whether to trim whitespace on each line. If enabled, this will override the .
TrimWhitespace bool
Gets or sets a value indicating whether beginning and ending whitespace.
Type Type
Gets or sets the type to use when looking up the resource file.
ViewContext ViewContext
Gets or sets the view context (automatically set when using razor views).

Methods

Name Value Summary
GetContentAsync(TagHelperContext, TagHelperOutput) Task<string>
Gets the content/text that are to be localized.
GetParameters(TagHelperContext) IEnumerable<object>
Gets the parameters to use when localizing the text.
Init(TagHelperContext) void
Initializes this Localize Tag Helpers, setting the html localizer and creating a stack list for child tag helpers to add parameters to.
ProcessAsync(TagHelperContext, TagHelperOutput) Task
The function responsible for acquiring the text to localize, getting the required parameters to pass to the localized text and replacing the old text with the new localized text.
SetContent(TagHelperContext, TagHelperContent, string) void
Sets the localized content back to where the original content was.
SetHtmlContent(TagHelperContext, TagHelperContent, IHtmlContent) void
Sets the localized content without encoding it back to where the original content was.

See Also

  • Microsoft.AspNetCore.Razor.TagHelpers.TagHelper