Usage in templates

Read a translation with the wrT pipe, the [wrT] directive or the WrI18n service.

Locale switcher

Switch the locale to see the demos below update.

Active locale:

Pipe

<h1>{{ 'app.title' | wrT }}</h1>
<p>{{ 'app.hello' | wrT: { name: user().name } }}</p>
<button>{{ 'common.save' | wrT }}</button>

Save

Cancel

Directive

Replaces the element's text with the translation.

<h1 [wrT]="'app.title'"></h1>
<p [wrT]="'app.hello'" [wrTParams]="{ name: user().name }"></p>

Save

Service

t() returns a string, translate() a signal.

const i18n = inject(WrI18n);

i18n.use('ru');
i18n.t('app.hello', { name: 'Ada' }); // 'Привет, Ada!'

const title = i18n.translate('app.title'); // Signal<string>

use() switches text only. Dates and numbers follow Angular's LOCALE_ID, which needs a reload.

See also