sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.45k stars 2.1k forks source link

searchtools.js substitutes variable before translation #11008

Open jpmckinney opened 1 year ago

jpmckinney commented 1 year ago

Describe the bug

The code uses backticks, which substitutes resultCount. The new string is then passed to gettext() (_()).

https://github.com/sphinx-doc/sphinx/blob/b1ca6b3e120d83c9bb64fdea310574afb9897c1a/sphinx/themes/basic/static/searchtools.js#L111-L113

However, the new string doesn't match any translatable string:

https://github.com/sphinx-doc/sphinx/blob/b1ca6b3e120d83c9bb64fdea310574afb9897c1a/sphinx/locale/es/LC_MESSAGES/sphinx.js#L40

How to Reproduce

  1. Click https://www.sphinx-doc.org/es/master/search.html?q=here
  2. Observe "Search finished, found 31 page(s) matching the search query." instead of "Búsqueda finalizada, se encontraron 31 páginas que coinciden con la consulta de búsqueda."

Environment Information

Platform:              darwin; (macOS-13.0.1-arm64-arm-64bit)
Python version:        3.8.12 (default, Dec  8 2021, 19:03:58) 
[Clang 13.0.0 (clang-1300.0.29.3)])
Python implementation: CPython
Sphinx version:        5.3.0
Docutils version:      0.18
Jinja2 version:        3.1.2

Sphinx extensions

No response

Additional context

No response

hajs commented 1 year ago

Hello there, I created a fix which works for me: https://github.com/hajs/sphinx/commit/8e6a9cb7ddbfbb24c5057946d15248648dd4f3d5

Should I submit a pull request?

AA-Turner commented 1 year ago

Please!

A