angular-gettext icon indicating copy to clipboard operation
angular-gettext copied to clipboard

Missing translate when text node have [<>&]

Open aromanyukvakoms opened this issue 10 years ago • 2 comments

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 &gt; bla bla &amp; <span> just another text &gt; &lt; &amp; 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 &gt; &lt; &amp;

what do you think about this?

aromanyukvakoms avatar Apr 09 '15 13:04 aromanyukvakoms

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?

84m avatar Sep 16 '15 17:09 84m

Why don't you try {{ "My super text > bla bla &" | translate }} instead?

CharlesHamel avatar Sep 16 '15 17:09 CharlesHamel