rbalet / ngx-translate-multi-http-loader

A loader for ngx-translate that loads translations with http calls
MIT License
77 stars 15 forks source link

Non-string values are not being translated #37

Open xRino94 opened 1 day ago

xRino94 commented 1 day ago

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 commented 1 day ago

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