Skip to the content
Documentation

encoding and html entities

No ratings yet

Using special charaters, accents and so on, generaly works fine (as long as you properly set the caracter encoding of the files, of course), but if you would like to use html entities instead, you should "double code" the translation.ts file :
"é" should become "é"
"&" should become "&"
">" should become ">"
etc...
For example : if the string you would like to convert looks like
let's do it
and the source code of your template is
{"let's do it"|i18n()}
then the translation.ts should contain the following message :
<message>
<source>let&amp;apos;s do it</source>
<translation>translated let&amp;apos;s do it</translation>
</message>
It seems that exponential parses the html entities in the translation.ts file first before it actualy compares the messages. I'm not sure why it actualy performs that way, but it sure is something you should know about since the whole translation file can get rejected if it encounters quotes ( ' or " ), greater than ( > ) or smaller than ( < ) since the parsed file is no longer a valid XML file...

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Re: encoding and html entities

    Saad ·

    You can also use CDATA if needed to "escape" non-valid xml characters:
    <message>
    <source>Drink a coffee</source>
    <translation><![CDATA[Boire un caf&eacute;]]></translation>
    </message>