Reputation: 886
I know this has cropped up a few times on here but I really can't find a suitable answer! i'm using angular-translate in a project, and I want to use the filter to pass an object with a variable value to the back-end.
Here's how I'm implementing the use of the translate filter:
{{ 'BUTTON_BUY' | translate: { RES: product.images.length } }}
I have tried wrapping the object in double quotes {{ 'BUTTON_BUY' | translate: "{ RES: product.images.length }" }}
, and I also tried escaping quotes but that doesn't work either. I have tried passing just RES: 1 and RES: 2 to check my translations pluralise properly and they do, so that leads me to believe that the issue lies in the way I am using the filter.
This is all inside an ng-repeat
(product
being an object in said repeated array).
Am I doing something really obviously wrong here?
Upvotes: 1
Views: 97
Reputation: 886
As it turns out, we didn't actually have the required data. I can, however, confirm that the following works:
{{ 'BUTTON_BUY' | translate: { RES: product.imgQuantity } }}
where RES is the name of the property in your JSON / Resx. For example, we went for the resx route in MVC, and this is our value:
Choose {RES, plural, one{Picture} other{Pictures}} & Buy
.
Upvotes: 2