Inline translation component. Renders translated text for a given key, resolved from the nearest ancestor <x-i18n-provider>.
<x-i18n key="greeting.hello" params='{"name":"World"}'></x-i18n>
| Attribute | Type | Default | Description |
|---|---|---|---|
key | string | "" | Dot-notation translation key |
params | string | "" | JSON string for interpolation |
| Property | Type | Reflects | Read-only | Description |
|---|---|---|---|---|
key | string | key | no | Translation key |
params | string | params | no | JSON interpolation params |
value | string | no | yes | Current resolved text |
None.
None.
| Property | Default | Description |
|---|---|---|
--x-i18n-font | inherit | Font family for the translated text |
--x-i18n-color | inherit | Text color |
| Part | Description |
|---|---|
text | The span containing the translated text |
Keys use dot-notation to walk nested translation objects:
{
"greeting": {
"hello": "Hello {name}!"
}
}
<x-i18n key="greeting.hello" params='{"name":"World"}'></x-i18n>
<!-- Renders: Hello World! -->
Placeholders in the format {key} are replaced with values from the params JSON:
<x-i18n key="message" params='{"count":"5","user":"Alice"}'></x-i18n>
Missing placeholder keys are left as-is in the output.
When no <x-i18n-provider> ancestor is found, the component displays the raw key string as fallback text.
The component renders as inline text (display: inline). The translated text is directly accessible to screen readers as regular text content.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |