Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin authored Apr 24, 2024
2 parents 2a3d2f4 + ad3f68f commit 471e4ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 471e4ff

Please sign in to comment.