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

Non-string values are not being translated #37

Open
xRino94 opened this issue Dec 2, 2024 · 1 comment
Open

Non-string values are not being translated #37

xRino94 opened this issue Dec 2, 2024 · 1 comment

Comments

@xRino94
Copy link

xRino94 commented Dec 2, 2024

Issue:
Non-string values are not being translated

Description:
When loading a translation file that contains non-string values (such as numbers or booleans), these values do not get properly translated or rendered in the application.

For example, given the following JSON translation file:

{
  "numericValue": 1,
  "booleanValue": false,
  "stringValue": "Foo bar"
}

If you attempt to translate these keys in the template:

{{ "numericValue" | translate }}
{{ "booleanValue" | translate }}
{{ "stringValue" | translate }}

Only "stringValue" will be translated (i.e., "Foo bar" will be displayed), while "numericValue" and "booleanValue" will not be processed as expected.

Expected behavior:
All values, including non-string values (numbers, booleans, etc.), should be handled consistently.

Suggested solution:
It would be helpful to automatically convert non-string values (such as numbers and booleans) to strings.

@rbalet
Copy link
Owner

rbalet commented Dec 2, 2024

Hi @xRino94, Good idea.

You can always do a PR.
But I won't be able to work on that project before January sry (merging a PR should be doable thought).

That said, it will slow down the library (I know. It for a lot), but I'm wondering if this is really worth it though.

Why can't you just change it into string in your i18n file?

Cheers

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