- Copy the
en
folder and rename it to the language you are adding. - Translate files in the new folder.
- Add header
x-custom-lang
to the request with the language you want to use.
import { I18nContext } from 'nestjs-i18n';
// code ...
@Injectable()
export class SomeService {
// code ...
async someMethod(): Promise<void> {
const i18n = I18nContext.current();
if (!i18n) {
throw new Error('I18nContext is not available');
}
const emailConfirmTitle = await i18n.t('common.confirmEmail');
// code ...
}
}
Previous: Automatic update of dependencies