Skip to content

Commit

Permalink
Merge pull request #625 from psyrenpark/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin authored Mar 28, 2024
2 parents 490fed6 + f822514 commit ad3f68f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/guides/type-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<I18nTranslations>
){}

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.

Expand Down

0 comments on commit ad3f68f

Please sign in to comment.