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

Spanish translation: fix bad substitution templates #8943

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

askhl
Copy link
Contributor

@askhl askhl commented Mar 1, 2021

Subject: Fix crash when building in Spanish locale

Feature or Bugfix

  • Bugfix

Purpose

This PR fixes the Spanish translation so it will not crash sphinx-build.

Detail

There are two translatable strings which are formatted in a way which prevents msgfmt from detecting a bad variable name in a string template, hence crashing at runtime when the error could have been found at translation compile time.

Aside from this immediate fix, I offer to submit a new PR which changes those strings so errors will be detected at compile time in the future.

Relates

This will fix #8930 (which is currently closed due to missing info).

@askhl
Copy link
Contributor Author

askhl commented Mar 1, 2021

More info follows.

The build log is this:

# Sphinx version: 3.5.2+/8144c5222
# Python version: 3.8.5 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 2.11.2
# Last messages:
#   escribiendo salida... [  4%] devel/devel
#   escribiendo salida... [  4%] devel/developer_installation
#   escribiendo salida... [  4%] devel/developersguide
#   escribiendo salida... [  5%] devel/eigenvalues_of_core_states
#   escribiendo salida... [  5%] devel/electrostatic_potential
#   escribiendo salida... [  5%] devel/formulas
#   escribiendo salida... [  6%] devel/grids
#   escribiendo salida... [  6%] devel/matrices
#   escribiendo salida... [  6%] devel/newrelease
#   escribiendo salida... [  7%] devel/others
# Loaded extensions:
#   sphinx.ext.mathjax (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /home/askhl/.local/lib/python3.8/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /home/askhl/.local/lib/python3.8/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (1.0.3) from /home/askhl/.local/lib/python3.8/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.4) from /home/askhl/.local/lib/python3.8/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /home/askhl/.local/lib/python3.8/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /home/askhl/.local/lib/python3.8/site-packages/alabaster/__init__.py
#   images (unknown version) from ./images.py
#   ext (unknown version) from ./ext.py
#   sphinx.ext.autodoc.type_comment (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.doctest (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/doctest.py
#   sphinx.ext.extlinks (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/extlinks.py
#   sphinx.ext.viewcode (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/viewcode.py
#   sphinx.ext.intersphinx (3.5.2+/8144c5222) from /home/askhl/src/sphinx/sphinx/ext/intersphinx.py
Traceback (most recent call last):
  File "/home/askhl/src/sphinx/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/home/askhl/src/sphinx/sphinx/application.py", line 352, in build
    self.builder.build_update()
  File "/home/askhl/src/sphinx/sphinx/builders/__init__.py", line 296, in build_update
    self.build(to_build,
  File "/home/askhl/src/sphinx/sphinx/builders/__init__.py", line 360, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/askhl/src/sphinx/sphinx/builders/__init__.py", line 534, in write
    self._write_serial(sorted(docnames))
  File "/home/askhl/src/sphinx/sphinx/builders/__init__.py", line 541, in _write_serial
    doctree = self.env.get_and_resolve_doctree(docname, self)
  File "/home/askhl/src/sphinx/sphinx/environment/__init__.py", line 538, in get_and_resolve_doctree
    self.apply_post_transforms(doctree, docname)
  File "/home/askhl/src/sphinx/sphinx/environment/__init__.py", line 584, in apply_post_transforms
    transformer.apply_transforms()
  File "/home/askhl/src/sphinx/sphinx/transforms/__init__.py", line 86, in apply_transforms
    super().apply_transforms()
  File "/home/askhl/.local/lib/python3.8/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/home/askhl/src/sphinx/sphinx/transforms/post_transforms/__init__.py", line 42, in apply
    self.run(**kwargs)
  File "/home/askhl/src/sphinx/sphinx/transforms/post_transforms/__init__.py", line 98, in run
    self.warn_missing_reference(refdoc, typ, target, node, domain)
  File "/home/askhl/src/sphinx/sphinx/transforms/post_transforms/__init__.py", line 177, in warn_missing_reference
    logger.warning(msg % {'target': target},
ValueError: unsupported format character '(' (0x28) at index 48

Basically the target string needs to be in the translated string.

It's the double %% in the string msgid "%s:%s reference target not found: %%(target)s" which prevents msgfmt from detecting the error.

Disclaimer: I'm not used to the build system so I didn't yet succeed in installing my updated translation and verifying that it works.

@askhl
Copy link
Contributor Author

askhl commented Mar 1, 2021

Disclaimer: I'm not used to the build system so I didn't yet succeed in installing my updated translation and verifying that it works.

I succeeded now in verifying that this fix works.

@tk0miya tk0miya added this to the 4.0.0 milestone Mar 2, 2021
@tk0miya tk0miya merged commit 99d97c6 into sphinx-doc:3.5.x Mar 2, 2021
@tk0miya
Copy link
Member

tk0miya commented Mar 2, 2021

Thanks!

@tk0miya
Copy link
Member

tk0miya commented Mar 2, 2021

Note: I merged this into transifex manually.

@tk0miya tk0miya modified the milestones: 4.0.0, 3.5.2 Mar 2, 2021
tk0miya added a commit to tk0miya/sphinx that referenced this pull request Mar 4, 2021
tk0miya added a commit to tk0miya/sphinx that referenced this pull request Mar 4, 2021
tk0miya added a commit that referenced this pull request Mar 6, 2021
i18n: Fix wrong substitution message catalog for el and hr (refs: #8943)
This was referenced Mar 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants