I'm submitting a ...
[x] support request
Current behavior
Do you know if I can do something like this ?
let max = 35.99;
let message = this.translate.instant('Maximum amount allowed is {{max}}', { max: max });
When I run console.log(message); I get "Maximum amount allowed is {{max}}"
instead "Maximum amount allowed is 35.99"
I just trying to use "instant" inside a component., but I don't know if I am sending the interpolateParams correctly.
Expected/desired behavior
let max = 35.99;
let message = this.translate.instant('Maximum amount allowed is {{max}}', { max: max });
Output after console.log(message) => "Maximum amount allowed is 35.99"
what you ask make no sense with this library, interpolation will only work with keys, i mean for example
en.json:
{
//other keys
"max": "Maximum amount allowed is {{max}}"
}
then in typescript:
let message = this.translate.instant('max', {max: 35.99});
console.log(message); // this should display "Maximum amount allowed is 35.99"
i think that what you need is something like:
let max = 35.99; // or whatever value you want to set here (even a server response if were the case)
let message = `Maximum amount allowed is ${max}`;
Most helpful comment
what you ask make no sense with this library, interpolation will only work with keys, i mean for example
en.json:
then in typescript: