Skip to main content


nestjs-i18n uses string-format for formatting by default.

First define arguments in your translations

"HELLO": "Hello {username}",

To provide nestjs-i18n with the right arguments pass them down while doing the translation

i18n.t('test.HELLO', {args: { username: 'Toon' }})
// => Hello Toon

To define your own formatting function change the formatter. Read the instructions here.

Array arguments

You can also use an array of arguments

"HELLO": "Hello {0.username}, This library is {1.opinion}",
i18n.t('test.HELLO', {args: [{ username: 'Toon' }, {opinion: 'Terrible :\')'}]})
// => Hello Toon, This library is Terrible :')

Custom formatter

To use a custom formatter define the formatter option. This option takes a function with a template and ...args.

import { Module } from '@nestjs/common';
import * as path from 'path';
import { I18nJsonLoader, I18nModule } from 'nestjs-i18n';

imports: [
fallbackLanguage: 'en',
formatter: (template: string, ...args: any[]) => template,
loaderOptions: {
path: path.join(__dirname, '/i18n/'),
watch: true,
controllers: [],
export class AppModule {}