toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
642 stars 106 forks source link

I18nRequestScopeService removed #499

Closed linconsdev closed 1 year ago

linconsdev commented 1 year ago

How can we use translations inside NestJS services without I18nRequestScopeService? Can someone please share a simple example with me? I've tried with I18nService but it always translates to fallback language and I18nContext throws an error that dependency can not be resolved.

rubiin commented 1 year ago

Before 10, you can use I18nRequestScopeService. But as of version 10 and above, I18nRequestScopeService is removed . This because we now have async_hooks support. This allows you to get the current I18nContext by doing I18nContext.current(). That being said, you can follow here for translation for services https://github.com/toonvanstrijp/nestjs-i18n/blob/main/samples/simple/src/app.service.ts. Feel free to open if the issue persists