mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
121 stars 58 forks source link

XML: Attributes inside attribute-folded inline and placeholder should be able to be translated #391

Closed k-yaegashi closed 1 year ago

k-yaegashi commented 1 year ago

In the current implementation, all attributes in attribute-folded inline elements or placeholder elements cannot be translated.

Consider this example

<?xml version="1.0" encoding="utf-8"?>
<doc>
  <p>
    Here I put an image.
    <image src="path/to/image.png" alt="This information is important for blind users." />
    If the image is not shown, please see the alternative text.
  </p>
</doc>

with the following configuration:

[po4a_langs] ja
[po4a_paths] test.pot ja:ja.po

[po4a_alias:spec] xml opt:"-o \"attributes=<image>alt\" -o \"inline=<image>\" -o \"foldattributes\""

[type: spec] test.xml ja:output.xml

In this case, an user usually wants to translate alt attribute and ignore src attribute. In order to do that in the current implementation, the user must give up foldattributes and therefore the message catalogs will be complicated. Same applies to placeholder.

In order to take full advantage of inline, foldattributes and placeholder options to make message catalogs smarter, attributes inside inline and placeholder elements should be able to be translated by specifying attributes option.

mquinson commented 1 year ago

Fixed with PR #390. Thanks!