Closed NeoKms closed 1 year ago
I have same problem. Did you resolve this problem ? @NeoKms
I have same problem. Did you resolve this problem ? @NeoKms
No, I didn't
Its because you are using i18nservice for transaltion. Its not request scoped so , it has no way of accessing the language the resolver has resolved to.
Update the code to throw new BadRequestException(this.i18n.t('auth.errors.wrong_login_or_password',{ lang: I18nContext.current().lang}))
@rubiin correct me ff I'm wrong, but maybe we can improve the I18nService to grab the I18nContext.current().lang if not language is provided? This way you don't have to do it manually?
@toonvanstrijp yeah we can do it. I have updated the docs section too . I will make a pr for it. in next release.
There are two languages. English (en) and French (fr). The default is French. I wrote my own resolver (just for clarity, I tried everything - none of them work). The resolver always returns "en". Everything is exactly translated into "fr".
Resolver:
Module:
I get a console output that the resolver worked.
nestjs version 9.4.0
Repo with simple proj: https://github.com/NeoKms/i18ntest (npm i && npm run start:dev
) Route: [post]/auth/sendCode
with payload{"email": "test@gmail.com"}