i18next / ng-i18next

translation for AngularJS using i18next
https://github.com/i18next/ng-i18next
MIT License
161 stars 54 forks source link

Incompatibility with ng-class #61

Closed rraziel closed 10 years ago

rraziel commented 10 years ago

Hello,

Maybe I'm using the directive wrong, but simple example:

<a ng-class="{'someclass': $first}" ng-i18next="panel.id" ng-repeat="panel in panels"></a>

This doesn't apply "someclass". Simply removing the ng-i18next attribute fixes it. Right now I'm doing this as a workaround:

<a ng-class="{'someclass': $first}" title="{{panel.id | i18next}}" ng-repeat="panel in panels"></a>
bugwelle commented 10 years ago

Hello,

The ng-i18next directive sees the attribute's value as a string to translate. Please try following:

<a ng-class="{'someclass': $first}" ng-i18next="{{panel.id}}" ng-repeat="panel in panels"></a>

And if you want to have a translated title try this:

<a ng-class="{'someclass': $first}" ng-i18next="[title]{{panel.id}}" ng-repeat="panel in panels"></a>

Working example: http://jsbin.com/tulibevodeke/1/ In this example both of your examples work. All links should have a title based on their ID. ;)

Regards, Andre

Update:// Please let me know if I understood something wrong. :)

rraziel commented 10 years ago

Ah yes, I tried again and it does work indeed... thanks :)

bugwelle commented 10 years ago

You're welcome :) You only forgot the braces around panel.id. I'm glad that I was able to help you.