Mehmet Noyan Aydin
Mehmet Noyan Aydin

Reputation: 289

how to make $translate.instant interpolation instead of concatenation

I am using translate.instant and making a string concatenation like that

var variable = this.$translate.instant('project.discount') + " % " + this.$translate.instant('project.applied_to') + " " +this.office;

how can I do that inside one $translate.instant as string interpolation instead of concatenation

Thanks,

Upvotes: 2

Views: 4797

Answers (1)

S. Baggy
S. Baggy

Reputation: 958

I think what you want is

var variable = this.$translate.instant('project.discountAndAppliedTo', {office: this.office});

Assuming

{
  "project.discountAndAppliedTo": "discount % applied to {{office}}"
}

Or something like that, with the key point being your interpolation variable name in {{}} in the translated value.

Upvotes: 5

Related Questions