transloco icon indicating copy to clipboard operation
transloco copied to clipboard

Feature(core): nested object in parameters

Open ben12 opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Which Transloco package(s) will this feature affect?

Transloco

Is your feature request related to a problem? Please describe

Nested object in parameters are note handled.

Example: en.json

{
  "range": "From {{range.start}} to {{range.end}}"
}
const data = {
  range: {
    start: 1,
    end: 10
  }
};
translocoService.translate("range", data);

Returns "From to ".

Describe the solution you'd like

It should return "From 1 to 10".

Describe alternatives you've considered

A workaround is to use flatten:

translocoService.translate("range", flatten(data));

But it is not possible to consider this "solution" when using pipe.

Additional context

No response

I would like to make a pull request for this feature

Yes 🚀

ben12 avatar Apr 28 '23 16:04 ben12

@ben12 Looks good on my end, you are welcome to open a PR for it 👍

shaharkazaz avatar May 10 '23 11:05 shaharkazaz

Any update on this one? Thxs

f-aubert avatar Oct 02 '23 18:10 f-aubert

@shaharkazaz Wouldn't it make sense to modify lines 52-54 of the default transpilers.ts to call getValue (helpers.ts), thus effectively allowing nested access to params in interpolations.

f-aubert avatar Feb 11 '24 18:02 f-aubert