angular-gettext
angular-gettext copied to clipboard
Missing translate when text node have [<>&]
Actually i don't know if I can call this Bug, but this should be at least documented somehow in module documentation. The problem is in translate directive text searching in array of translations, code from directive.js
var msgid = trim(element.html());
and for example we have Angular HTML tempalte:
<div transalte>My super text > bla bla & <span> just another text > < & bla </span></div>
the angular extractor gets next source:
My super text > bla bla & <span> just another text > < & bla </span>
but element.html():
My super text > bla bla & <span> just another text > < & bla </span>
so, as you see you get missing translation for strings which have text child with those 'special'(actually HTML5 say we can no more use XHTML rules?) characters.
I see two ways to solve this problem - write some recursive function for getting something like raw html
or simple don't use <>& and use XHTML > < &
what do you think about this?
I'd love to see a solution were i don't have to hack around the extraction (which is what i'm doing right now) but can just extract the string as usual and let it get parsed by the directive.
Any chances to get rid of the .html() so exraction and directive actually use the same string?
Why don't you try {{ "My super text > bla bla &" | translate }} instead?