angular-gettext
angular-gettext copied to clipboard
add object with translations to directive attribute
Add translation params to a directive.
<span translate="{username: 'Dexter'}">Hello {{username}}!</span>
forgot to compile and fixed update. new PR in progress
FYI you can just force push to a PR instead of opening a new one.
On Wednesday, September 30, 2015, Mischa Brammer [email protected] wrote:
Closed #222 https://github.com/rubenv/angular-gettext/pull/222.
— Reply to this email directly or view it on GitHub https://github.com/rubenv/angular-gettext/pull/222#event-423128501.
I've refrained from the value of the translate attribute until now because I see two potential problems:
- What will this do with regards to performance?
- What shall we do with Jade, which has the bad habit of compiling this markup:
div(translate) test
To this:
<div translate="translate">test</div>
I had a little bit time to fix these issues. Regarding your points.
- There shouldn't be any big performance issue, because the
update()is just triggered when something changed inside the scope of the directive. - I fixed this by testing if the attribute is an object or not.
translateValuesis undefined in case of<div translate="translate">test</div>
- There shouldn't be any big performance issue, because the update() is just triggered when something changed inside the scope of the directive.
Well, you do have the two eval calls, which for a Jade user would happen for every string. I'm not familiar with how eval is implemented in Angular.JS (should look it up), but I doubt it'll be a lightweight operation :-)