Open MrGeneration opened 11 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:
First, in the base.rst
file of the original language, you include your mermaid graph. The graph is stored in a separate file called mermaid.mmd
After this paragraph follows a mermaid graph:
.. mermaid:: mermaid.mmd
:align: center
mermaid.mmd
file, you have your mermaid graph, i.e.:
flowchart TD
S(((Beginning)))
T[End]
S--towards-->T
mermaid.de.mmd
like so.
flowchart TD
S(((Anfang)))
T[Ende]
S--bis-->T
./
+ base.rst
+ mermaid.mmd
+ mermaid.de.mmd
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
Hey,
it would be great if
sphinx-mermaid
would have internationalization support so that you can render diagrams in several languages.