tFragment
Translates a sentence like t, but places DOM nodes at its {{name}} placeholders.
Each key of nodes is a placeholder of the translated sentence. Its value is placed where the translation puts that placeholder, so 'Running for {{duration}} milliseconds' and a translation that moves {{duration}} to the end both render correctly. Every other placeholder is interpolated by i18next as usual, from options.
A Node placeholder used more than once is placed at its first position and deep-cloned at the later ones; a builder runs once per position. A placeholder the translation leaves out is not placed at all.
Import:
import { tFragment } from '@mnaoumov/obsidian-lib/i18n/t-fragment';Signature:
function tFragment(selector: SelectorParam, nodes: Readonly<Record<string, TranslationNode>>, options: Readonly<Record<string, unknown>> | undefined): DocumentFragmentParameters:
| Parameter | Type | Description |
|---|---|---|
selector |
SelectorParam | The translation selector, as t takes it. |
nodes |
Readonly<Record<string, TranslationNode>> | The DOM values of the placeholders, by placeholder name. |
options |
Readonly<Record<string, unknown>> | undefined | The i18next options, including the plain values of the other placeholders. |
Returns: DocumentFragment — A fragment holding the translated sentence with the nodes in place.
Links to this page: