AngularJS pluralization with angular-translate and ng-pluralize

angularjs, angularjs-ng-pluralize, internationalization

Solution

I was looking for the same answer and come up with this solution: Escape the quotes for the translation key with &quot ;

<ng-pluralize count="comment.Comment.like_count"
    when="{'0': '{{&quot;LIKES_LIKE&quot; | translate}}',
        'one': '{{&quot;LIKES_LIKE&quot; | translate}}',
        'other': '{{&quot;LIKES_LIKES&quot; | translate}}'}">
</ng-pluralize>

or use a ng-int value object (you could also define these values on your controller)

<ng-pluralize count="comment.Comment.like_count"
    ng-init="likes_like='LIKES_LIKE'; likes_likes='LIKES_LIKE'"
    when="{'0': '{{likes_like | translate}}',
        'one': '{{likes_like | translate}}',
        'other': '{{likes_likes | translate}}'}">
</ng-pluralize>

For interpolation on teh count value you could use

<ng-pluralize count="comment.Comment.like_count"
    when="{'0': '{{LIKES_LIKE | translate}}',
        'one': '{{LIKES_LIKE | translate}}',
        'other': '{{LIKES_LIKES | translate:{count : comment.Comment.like_count} }}'}">
</ng-pluralize>

Where LIKES_LIKES = "{{count}} likes"

http://plnkr.co/edit/TdBPfhqMGuxtWDg28lAV?p=preview

Problem

I have this piece of code code ``` <ng-pluralize count="comment.Comment.like_count" when="{'0': {{'LIKES_LIKE' | translate}}, 'one': {{'LIKES_LIKE' | translate}}, 'other': '{{'LIKES_LIKES' | translate}}}"> </ng-pluralize> ``` but I can't figure out how to Format the string so that it actually parses the likes strings by the translate filter so that the ng-pluralize directive receives the parsed language string. The error messge is this: Error: [$parse:lexerr] Lexer Error: Unterminated quote at columns 107-123 [' | translate}}}] in expression [{'0': {{'LIKES_LIKE' | translate}}, 'one': {{'LIKES_LIKE' | translate}}, 'other': '{{'LIKES_LIKE' | translate}}}]. I'm well aware what i means but I can't figure out how to make it work. Any ideas?

Original source