rubenv / angular-gettext

Gettext support for Angular.js
http://angular-gettext.rocketeer.be/
MIT License
650 stars 154 forks source link

Ignore native HTML translate attribute #371

Closed cmlenz closed 3 years ago

cmlenz commented 3 years ago

Update the translate directive to gracefully handle the native HTML translate="yes|no" attribute.

This change will bypass the normal angular-gettext processing when the translate attribute has a value.

We ran into this problem because sticking a translate="no" attribute onto the body element to disable the Chrome translate toolbar from showing up broke the whole application :)

rubenv commented 3 years ago

I've seen some HTML frameworks (jade/pug) generate a translate="translate" attribute, which might break due to this. Might need a special case for that.

cmlenz commented 3 years ago

I've seen some HTML frameworks (jade/pug) generate a translate="translate" attribute, which might break due to this. Might need a special case for that.

Good point, that'd basically the XHTML form for boolean attributes. Not quite correct, but it doesn't hurt to handle that.

What'd be preferable: whitelisting "yes" and "no", or blacklisting "translate"?

Also, not sure why the tests failed on Travis, running them locally seems okay.

cmlenz commented 3 years ago

I have updated the PR to whitelist the "yes" and "no" values, so all other values will let the normal processing continue as before.

rubenv commented 3 years ago

Great!

Yeah Travis... :man_shrugging:

Somebody needs to look into that but I don't have the time to do it sadly.

rubenv commented 3 years ago

Looks good otherwise, thanks a lot! Will publish to NPM

cmlenz commented 3 years ago

Thanks!