Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations are removed when args are not present #632

Open
5 tasks done
kashyap-aditya opened this issue May 3, 2024 · 2 comments
Open
5 tasks done

Translations are removed when args are not present #632

kashyap-aditya opened this issue May 3, 2024 · 2 comments

Comments

@kashyap-aditya
Copy link

Describe the bug

let translatedText: T = await this.i18nRequestScopedService.translate("CAT_NAME", {
lang: 'en-us',
});

key points to a json file with this:
"CAT_NAME": "My cats name is {name}"

In v8.3.0, the returned text is : "My cats name is {name}"
In v8.3.1, the returned text is: "My cats name is {}"

I am quite confident that the issue is because in i18n.service.ts, there is a line:
const args = options?.args ?? {};

but because of that, even when the passed in options.args is undefined, it gets set to {} and hence the second part of the following boolean always translates to true:
if (translation && (args || (args instanceof Array && args.length > 0)))

Reproduction

let translatedText: T = await this.i18nRequestScopedService.translate("CAT_NAME", { lang: 'en-us', }); key points to a json file with this: "CAT_NAME": "My cats name is {name}" In v8.3.0, the returned text is : "My cats name is {name}" In v8.3.1, the returned text is: "My cats name is {}" I am quite confident that the issue is because in i18n.service.ts, there is a line: const args = options?.args ?? {}; but because of that, even when the passed in options.args is undefined, it gets set to {} and hence the second part of the following boolean always translates to true: if (translation && (args || (args instanceof Array && args.length > 0)))

System Info

node 18.20.2

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@rubiin
Copy link
Collaborator

rubiin commented May 3, 2024

Can you try the latest?

@kashyap-aditya
Copy link
Author

Can you try the latest?

I can't without breaking my company's codebase. There are breaking changing in the latest version.
I actually think it was fixed in V9.1.6
#369

But I am wondering if it would be possible to create a version 8.3.3 with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants