{
"app": {
"title": "Welcome",
"hello": "Hello, {{name}}!",
"items": "{{count}} item(s) selected"
}
}Interpolation
Fill placeholders in a translation with values.
Catalog shape
Wrap the param name in double braces; a param missing from the object renders as nothing.
Live
Type a name.
<p>{{ 'app.hello' | wrT: { name: user().name } }}</p>
<p>{{ 'app.items' | wrT: { count: selection().length } }}</p>Reusable formatter
useI18nFormatter(key, fallback) returns a function of the params, for a label reused per row.
import { useI18nFormatter } from 'ngwr/i18n';
const formatItems = useI18nFormatter('app.items', '{{count}} item(s) selected');
formatItems({ count: 3 }); // '3 item(s) selected'See also
Pipe wrPluralPick the right word form for a count, in any language.Guide Usage in templatesRead a translation with the wrT pipe, the [wrT] directive or the WrI18n service.Service WrI18nTranslate strings at runtime and switch the locale without a reload.Pipe wrNumberFormat a number, percent or price in the app locale.