diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-18 20:12:41 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-19 06:58:28 +0300 |
commit | 897be0ebae09117d64222dcee23daa80d32a28cb (patch) | |
tree | 223fe4d4680c9a0151011d1c76955cbf99c0fadb /sphinx/transforms | |
parent | 82a149f4f33ad3f36d96590b58006e64c6bada59 (diff) |
Close #7784: i18n: The alt text for image is translated by default
Make alt text for image translatable by default without settings of
gettext_additional_targets.
Diffstat (limited to 'sphinx/transforms')
-rw-r--r-- | sphinx/transforms/i18n.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sphinx/transforms/i18n.py b/sphinx/transforms/i18n.py index e6a12b962..028044de2 100644 --- a/sphinx/transforms/i18n.py +++ b/sphinx/transforms/i18n.py @@ -237,6 +237,10 @@ class Locale(SphinxTransform): node.details['nodes'][0]['content'] = msgstr continue + if isinstance(node, nodes.image) and node.get('alt') == msg: + node['alt'] = msgstr + continue + # Avoid "Literal block expected; none found." warnings. # If msgstr ends with '::' then it cause warning message at # parser.parse() processing. @@ -440,8 +444,9 @@ class Locale(SphinxTransform): if isinstance(node, LITERAL_TYPE_NODES): node.rawsource = node.astext() - if isinstance(node, IMAGE_TYPE_NODES): - node.update_all_atts(patch) + if isinstance(node, nodes.image) and node.get('alt') != msg: + node['uri'] = patch['uri'] + continue # do not mark translated node['translated'] = True # to avoid double translation |