Namespace Tlumach.Templating
Classes
- TemplateArguments
The values, which a template passes to one call of TemplateTranslator for the placeholders of a translation.
Positional values fill indexed placeholders (
{0},{1}) and, by position, named placeholders without a named value. Named values fill named placeholders; their names are case-insensitive.
- TemplateKeyNotFoundException
Thrown by TemplateTranslator for a key that no translation contains, when MissingKey is Throw.
- TemplateTranslationOptions
The options of TemplateTranslator, shared by the integrations with template engines, whose options derive from this class.
TemplateTranslator copies the values when it is created, so later changes of an options object do not affect a registered integration.
- TemplateTranslator
Retrieves translations for template engines. It resolves the culture of a call, looks up a text by key or by translation unit, fills the placeholders of the text with the values of the call, and handles missing keys.
Texts are read from translation entries without the encoding of WebEncodeValues, so that a template engine encodes them exactly once. An instance does not change after it is created and may be used by many renders concurrently.
The fallback to the values of a translation unit (the values cached with CachePlaceholderValue(string, object?) and the values supplied by OnPlaceholderValueNeeded) is process-wide: generated units are static singletons, so their subscribers and cached values are shared by all renders. It is not suitable for per-user values in concurrent renders; pass such values as arguments of the call.
Structs
- TemplateMarkup
A trusted HTML fragment passed as a placeholder value. TranslateMarkup(object?, TemplateArguments, CultureInfo, Func<string, string>) inserts it without encoding, and Translate(object?, TemplateArguments, CultureInfo) inserts its text as is.
Enums
- MissingKeyBehavior
Specifies what TemplateTranslator returns for a key that no translation contains.