Class TlumachText
Renders the text of a translation unit or of a key in the culture of the user and re-renders when the user switches the language.
The text is HTML-encoded like any other Razor output. If the translation manager encodes values itself (WebEncodeValues), the already encoded text is not encoded again. Set AsMarkup only for translations that contain trusted HTML; string placeholder values are HTML-encoded in that mode.
public sealed class TlumachText : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender
- Inheritance
-
TlumachText
- Implements
- Inherited Members
Properties
Args
Gets or sets the values of named placeholders, keyed by placeholder names.
[Parameter]
public IDictionary<string, object?>? Args { get; set; }
Property Value
AsMarkup
Gets or sets a value indicating whether the text is rendered as markup. Use it only for translations that contain trusted HTML.
The translation text is trusted, while placeholder values are data: string values in Args and Values are HTML-encoded before they are substituted. To insert trusted HTML through a value, pass a MarkupString. Other values (numbers, dates, ...) are formatted as usual.
[Parameter]
public bool AsMarkup { get; set; }
Property Value
Key
Gets or sets the key of the text, used when Unit is not set.
When the key has no text, the component renders the key itself as text (HTML-encoded, also with AsMarkup), as the string localizers and the MVC tag helpers do.
[Parameter]
public string? Key { get; set; }
Property Value
Manager
Gets or sets the translation manager that resolves Key. When not set, DefaultManager is used.
[Parameter]
public TranslationManager? Manager { get; set; }
Property Value
Unit
Gets or sets the translation unit, usually a member of a generated class, e.g. Strings.Hello.
[Parameter]
public BaseTranslationUnit? Unit { get; set; }
Property Value
Values
Gets or sets the values of indexed placeholders, used when Args is not set.
[Parameter]
public IReadOnlyList<object>? Values { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
builderRenderTreeBuilderA RenderTreeBuilder that will receive the render output.
OnParametersSet()
Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.
protected override void OnParametersSet()