-
Notifications
You must be signed in to change notification settings - Fork 153
Translation won't work if string contains & codes. #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@pySilver How exactly is translation not working? Are you using the |
@gabegorelick I'm using This <p translate>
Configure your website by navigating to <br> <strong>Ad Tools → Configure Contextual Ads</strong>.
</p> this <p translate>
Configure your website by navigating to <br> <strong>Ad Tools → Configure Contextual Ads</strong>.
</p> the only difference here is html entity |
Yup, known problem. I strongly recommend using UTF-8 instead of escaped entities for now. Every computer on the planet supports it nowadays. |
@rubenv What's the source of this bug? It seems very strange to me. |
I have no idea. There's an easy way to work around it (which is also much nicer to translators), so we never bothered looking into it. Just use UTF-8 :-). |
I found out that some angular template compilers convert '&', '>', '<', etc. in '&', '>', '<' ant this converted string will be passed to angular-gettext, which will be failed to match, since strings are collected on original file. In my case there was gulp
|
I think this is a bug and should work: But... if I add |
The "use UTF-8 character instead" workaround is unhandy if the character is not visible or not distinguishable from another character. For instance, I used the following workaround: <span ng-init="shy = '\u00ad'">
<span translate>foo{{shy}}bar</span>
</span> |
Special characters like |
Ran across this caveat myself today. The problem, as I noticed it, is that when compiling strings, the text as it was written is passed to the The resulting In use, the translate directive uses javascript to get the html of the element it was applied to, and sends it to the compile function for processing. At this time, the html entities have been converted into their plain text counter part. Then the lookup for a translation string fails as the msgid is different in the compiled translations and what is being used at that time. I prayed to google for possible answers on how, with javascript, to get raw contents of an element without interpreting special characters, and it seems this is a limitation of how javascript is able to access this information. I think a possible workaround may be to manually call the A possible resolution this package could do is interpret these html entities when compiling strings to prepare the msgid to have the literal character in it, which sounds moderately better, but still not ideal as it limits compatibility of the characters you can use. |
Extraction & futher translation of the string like this one, works fine:
But for string like the following one extraction would work, but translation would not:
Workaround for now would be using special symbols directly in a source code:
So clearly there is a problem with
&xxx;
symbols.The text was updated successfully, but these errors were encountered: