Skip to content
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

Doesn't unescape XML. #30

Open
murraycu opened this issue Nov 18, 2014 · 2 comments
Open

Doesn't unescape XML. #30

murraycu opened this issue Nov 18, 2014 · 2 comments

Comments

@murraycu
Copy link

If my strings.xml has a string such as this:

<string name="about_text2">This android app was developed by &lt;a href="http://murrayc.com/&quot;&gt;Murray Cumming&lt;a&gt;</string>

Then the strings.pot file (and the strings-*.po files) contains this:

msgctxt "about_text2"
msgid ""
"This android app was developed by &lt;a "
"href=http://murrayc.com/&gt;Murray Cumming&lt;a&gt;"
msgstr ""

These lt, gt and quot entities are entirely specific to XML so I wouldn't expect to see them in the .po file for translators to see.

I think there are at least some cases (full HTML to show in an HTML view?) where people really need to correctly escape their markup in strings.xml.

This could get awkward because Android also accepts unescaped markup in strings.xml, in which case it seems to parse the resulting child nodes and pretend that nothing odd happened. And that's actually the only way to have an a link in your TextView's text when specifying the text via the layout XML, so I have to set these in code via Html.fromHtml(getString(R.string.something)).

I actually started using the correct XML escaping in my strings.xml because a2po adds quotes around the strings when importing them back into strings.xml. Android seemes to ignore them, but it seemed odd and I considered it a bug in my strings.xml ratherr than a problem with a2po.

@murraycu
Copy link
Author

Actually, maybe I just shouldn't do this. This documentation
http://developer.android.com/guide/topics/resources/string-resource.html
under "Escaping apostrophes and quotes" says that "XML encodings" don't work.

@murraycu
Copy link
Author

Here's a bug report/question about those extra quotes when not escaping the markup:
#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant