mgaitan / sphinxcontrib-mermaid

Mermaid diagrams in yours sphinx powered docs
http://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest/
Other
328 stars 95 forks source link

Add translation support for mermaid #130

Open MrGeneration opened 11 months ago

MrGeneration commented 11 months ago

Hey,

it would be great if sphinx-mermaid would have internationalization support so that you can render diagrams in several languages.

jnuernberg commented 4 months ago

Hi, Through trial and error, I was able to figure out, that sphinx-intl can cope with mermaid graphs, if you include them as files and then use the same naming convention as for figure translations. I.e. you include the mermaid-graph as file, then translate it and save it to a new file, following the naming convention. In that case, the rightly translated graph will be picked up.

In the Sphinx options for internationalization, you can set the figure_language_filename to enable internationalization for figures. By default, this is {root}.{language}{ext}.

Let me give you an example:

With this structure, sphinx-intl will pick up the rightly translated mermaid graph for internationalization in your documentation.

However, there are some culprits: In particular, if you are using captions, these are not being caught, when running sphinx-build -M gettext. In other words, the following will show show the english caption in all of your translations and I reckon, that this is part of sphinxcontrib-mermaid.

  .. mermaid:: mermaid.mmd
    :align: center
    :caption: What a beautiful mermaid graph! 

I hope this helps,

Jacob