sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

feat: adapt image refuri if image uri has been adapten by i18n

Open koeppe-at-pdtec opened this issue 6 months ago • 15 comments

Subject: adapt image refuri if image uri has been adapten by i18n

Hello Dev-Team, i stumbled accross an issue, when using sphinx-intl and image references in figures.

Here is a solution that solves the problem for me. Maybe you like to include it to Sphinx.

Greets Alex

Feature or Bugfix

  • Feature

Purpose

  • When using sphinx-intl and let it automatically substitute translated images using config option figure_language_filename = "{root}.{language}{ext}" reference uri's defined via :target: declaration in figures are broken.

Example:

      .. figure:: ./cherry.png
         :alt: Two red cherries
         :figwidth: 30%
         :target: ./_images/cherry.png

         Two red cherries

For language de ./cherry.png is replaced by cherry.de.png if the image is found in the source dir. When HTML is built the file cherry.de.png is stored in _images but not cherry.png. So the reference gets broken for alle language specific images.

In my case i like to link to the corresponding translated image also in the reference.

Detail

  • adapt refuri according to image_uri

Example

cd example
sphinx-build .\source\ build\html\de -D language=de
sphinx-build .\source\ build\html\en -D language=en


  • image links ar brocken for german version

koeppe-at-pdtec avatar Aug 30 '24 09:08 koeppe-at-pdtec