i18next / ng-i18next

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

Ability to opt in for bindOnce #78

Closed tjosbon closed 9 years ago

tjosbon commented 9 years ago

As far as I am able to tell, there is not a way to setup the 'ngi18next' directive to bindOnce. Could the option be added? I noticed something similar was proposed in issue #52 where a 'watchOptions' property was added to the $i18nextProvider. In our application, it would not work to have the watch removed for all translations as there will likely be a mix in most applications. For example when a pluralized translation needs to be displayed due to multiple values being selected.

So, we are looking for something similar to available bind-once directive which allows for things like 'bo-if', etc. In cases where we do not want a watcher, we could use 'bo-ngi18next'.

I'd be happy to help by contributing a solution. Just checking first check and make sure I'm not overlooking a way to accomplish what I need with current implementation.

bugwelle commented 9 years ago

With version 0.4.0 there is now a simple directive called bo-i18next. It only changes on language-change-events but not if a variable is changed.

See: https://github.com/i18next/ng-i18next/blob/master/src/directive/directiveBindOnce.js , https://github.com/i18next/ng-i18next/blob/master/src/directive/directive.js#L165-L176

I hope that there aren't any bugs in it...