diff --git a/docs/guides/type-safety.md b/docs/guides/type-safety.md index 5ad61908..510a9714 100644 --- a/docs/guides/type-safety.md +++ b/docs/guides/type-safety.md @@ -52,6 +52,26 @@ export class AppController { } ``` +```typescript title="src/app.service.ts" +import { Injectable } from '@nestjs/common'; +import { I18nContext, I18nService } from 'nestjs-i18n'; +import { I18nTranslations } from './generated/i18n.generated.ts'; + +@Injectable() +export class AppService { + constructor( + private readonly i18n: I18nService +){} + + getHello() { + return this.i18n.translate("test.HELLO", { + lang: I18nContext.current()?.lang, + }); + } +} +``` + + :::tip You can import the `I18nPath` type so you require a valid i18n path in your code. This is useful when handeling exceptions with translations.