Skip to content

Doesn't unescape XML. #30

@murraycu

Description

@murraycu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions