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
| Name | Summary |
|---|---|
| Generic |
Initializes a new instance of the GenericLocalizeTagHelper class.
|
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.
|
| 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 |
Task |
Gets the content/text that are to be localized.
|
| GetParameters |
IEnumerable |
Gets the parameters to use when localizing the text.
|
| Init |
void |
Initializes this Localize Tag Helpers, setting the html localizer and creating a stack list
for child tag helpers to add parameters to.
|
| ProcessAsync |
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 |
void |
Sets the localized content back to where the original content was.
|
| SetHtmlContent |
void |
Sets the localized content without encoding it back to where the original content was.
|
See Also
- Microsoft.AspNetCore.Razor.TagHelpers.TagHelper