Open t2ym opened 5 years ago
xliff-conv
Name | Source | Preprocess | JSON | XLIFF | HTML | UI |
---|---|---|---|---|---|---|
non-breaking space | | |||||
non-breaking space | | | | |||
non-breaking space |   | | | |||
non-breaking space | N/A | N/A |   | | ||
non-breaking space (broken) | N/A | N/A | | N/A | | |
less than | < | < | < | < | < | < |
less than | < | < | < | < | < | < |
less than | < | < | < | < | < | < |
less than (broken) | N/A | N/A | < | N/A | &lt; | < |
greater than | > | > | > | > | > | > |
greater than | > | > | > | > | > | > |
greater than | > | > | > | > | > | > |
greater than (broken) | N/A | N/A | > | N/A | &gt; | > |
ampersand | & | & | & | & | & | & |
ampersand | & | & | & | & | & | & |
ampersand | & | & | & | & | & | & |
ampersand (broken) | N/A | N/A | & | N/A | & | & |
double quotation mark | " | " | \" | " | " | " |
double quotation mark | " | " | \" | " | " | " |
double quotation mark | " | " | \" | " | " | " |
double quotation mark | N/A | N/A | \" | " | " | " |
double quotation mark (broken) | N/A | N/A | " | N/A | &quot; | " |
single quotation mark | ' | \' | ' | ' | ' | ' |
single quotation mark | ' | \' | ' | ' | ' | ' |
single quotation mark | ' | \' | ' | ' | ' | ' |
single quotation mark | N/A | N/A | ' | ' | ' | ' |
single quotation mark (broken) | N/A | N/A | ' | N/A | &apos; | ' |
cent | ¢ | \xA2 | ¢ | ¢ | ¢ | ¢ |
cent | ¢ | \xA2 | ¢ | ¢ | ¢ | ¢ |
cent | ¢ | \xA2 | ¢ | ¢ | ¢ | ¢ |
cent (broken) | N/A | N/A | ¢ | N/A | &cent; | ¢ |
pound | £ | \xA3 | £ | £ | £ | £ |
pound | £ | \xA3 | £ | £ | £ | £ |
pound | £ | \xA3 | £ | £ | £ | £ |
pound (broken) | N/A | N/A | £ | N/A | &pound; | £ |
yen | ¥ | \xA5 | ¥ | ¥ | ¥ | ¥ |
yen | ¥ | \xA5 | ¥ | ¥ | ¥ | ¥ |
yen | ¥ | \xA5 | ¥ | ¥ | ¥ | ¥ |
yen (broken) | N/A | N/A | ¥ | N/A | &yen; | ¥ |
euro | € | \u20AC | € | € | € | € |
euro | € | \u20AC | € | € | € | € |
euro | € | \u20AC | € | € | € | € |
euro (broken) | N/A | N/A | € | N/A | &euro; | € |
euro (broken) | N/A | N/A | \\u20AC | \u20AC | \u20AC | \u20AC |
copyright | © | \xA9 | © | © | © | © |
copyright | © | \xA9 | © | © | © | © |
copyright | © | \xA9 | © | © | © | © |
copyright (broken) | N/A | N/A | © | N/A | &copy; | © |
registered trademark | ® | \xAE | ® | ® | ® | ® |
registered trademark | ® | \xAE | ® | ® | ® | ® |
registered trademark | ® | \xAE | ® | ® | ® | ® |
registered trademark (broken) | N/A | N/A | ® | N/A | &reg; | ® |
winking face emoji | 😉 | \uD83D \uDE09 | 😉 | 😉 | 😉 | 😉 |
winking face emoji | 😉 | \uD83D \uDE09 | 😉 | 😉 | 😉 | 😉 |
winking face emoji | N/A | N/A | \uD83D \uDE09 | N/A | 😉 | 😉 |
winking face emoji | N/A | N/A | 😉 | 😉 | 😉 | 😉 |
winking face emoji (broken) | N/A | N/A | 😉 | N/A | 😉 | 😉 |
return html`${bind(this)}
<div>message with HTML entities <😉>"& <br>
non-breaking space   <br>
< less than < < <br>
> greater than > > <br>
& ampersand & & <br>
" double quotation mark " " <br>
' single quotation mark (apostrophe) ' ' <br>
¢ cent ¢ ¢ <br>
£ pound £ £ <br>
¥ yen ¥ ¥ <br>
€ euro € € <br>
© copyright © © <br>
® registered trademark ® ® <br>
</div>
<div>message with newlines
next line
last line
</div>
`;
{
'div_4': [
'message with HTML entities <\uD83D\uDE09>"& {1}\n non-breaking space {2}\n< less than < < {3}\n> greater than > > {4}\n& ampersand & & {5}\n" double quotation mark " " {6}\n\' single quotation mark (apostrophe) \' \' {7}\n\xA2 cent \xA2 \xA2 {8}\n\xA3 pound \xA3 \xA3 {9}\n\xA5 yen \xA5 \xA5 {10}\n\u20AC euro \u20AC \u20AC {11}\n\xA9 copyright \xA9 \xA9 {12}\n\xAE registered trademark \xAE \xAE {13} ',
'<br>', // placeholder; no need to translate
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>',
'<br>'
],
'div_5': 'message with newlines\n next line\n last line '
}
{
"div_4": [
"message with HTML entities <😉>\"& {1}\n non-breaking space {2}\n< less than < < {3}\n> greater than > > {4}\n& ampersand & & {5}\n\" double quotation mark \" \" {6}\n' single quotation mark (apostrophe) ' ' {7}\n¢ cent ¢ ¢ {8}\n£ pound £ £ {9}\n¥ yen ¥ ¥ {10}\n€ euro € € {11}\n© copyright © © {12}\n® registered trademark ® ® {13} ",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>",
"<br>"
]
}
<source>message with HTML entities <😉>"& {1}
non-breaking space {2}
< less than < < {3}
> greater than > > {4}
& ampersand & & {5}
" double quotation mark " " {6}
' single quotation mark (apostrophe) ' ' {7}
¢ cent ¢ ¢ {8}
£ pound £ £ {9}
¥ yen ¥ ¥ {10}
€ euro € € {11}
© copyright © © {12}
® registered trademark ® ® {13} </source>
<target state="needs-translation">message with HTML entities <😉>"& {1}
non-breaking space {2}
< less than < < {3}
> greater than > > {4}
& ampersand & & {5}
" double quotation mark " " {6}
' single quotation mark (apostrophe) ' ' {7}
¢ cent ¢ ¢ {8}
£ pound £ £ {9}
¥ yen ¥ ¥ {10}
€ euro € € {11}
© copyright © © {12}
® registered trademark ® ® {13} </target>
</trans-unit>
<trans-unit id="world-clock-container.div_4.1">
<source><br></source>
<target state="needs-translation"><br></target><!-- placeholder; no need to translate -->
</trans-unit>
[lit-html] HTML entities in a part are shown as they are without decoding
Principles
- No HTML entities in JSON
- XML entities (subset of HTML entities) in XLIFF
Notes
demo/gulpfile.js
to decode HTML entities in JSON might have unexpected side effects on Safari browsers, which have some Unicode literal string issues (whose details unknown).Root Cause
lit-html
.lit-html
setstextNode.data
of HTML by parts, notinnerHTML
.lit-html
setsinnerHTML
by non-parts literals, while all the UI strings are converted to parts by I18N-readyhtml
``demo/gulpfile.js
JavaScript preprocessor does not decode HTML entities in JSONReproducible Code
<i18n-format>
template string, HTML entities are decoded as<i18n-format>
converts them.Considerations on potential fixes
html([str])
xliff-conv
if XLIFF is usedxliff-conv
. Raw Unicode characters or their codepoint HTML entities have to be used.https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
Workaround for translated strings
Workaround for parameters
html
without binding