executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
200 stars 80 forks source link

Support translated notebooks #600

Open OriolAbril opened 1 month ago

OriolAbril commented 1 month ago

Closes #587. The issue points to the relevant sphinx source, where it can be seen sphinx "marks" translated strings with <translated> at the end of the source_path argument, which is then stored as the current_source attribute of the docutils.nodes.document class, which is the second argument of Parser.parse.

This adds an extra condition to fall back to myst-parser which allows using myst-nb with translated content.

It would be nice to add some test for this but I am not familiar enough with the test suite yet, I'll try to add one in the coming days. It can probably reuse one of the existing notebooks, but it will be necessary to add a locale folder with the translations, will it be ok to add it directly in the tests folder?

So far I have only checked it works locally on a couple repos I had (both executing and not executing notebooks).

agoose77 commented 4 days ago

I won't include this in the current patch release, as I don't have enough bandwidth to avoid blocking the Jupyter Book release that needs to follow. I'll circle back around to this PR soon :)