-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nbTranslate #838
nbTranslate #838
Conversation
…lecting a language among severals
…ntrib_nbextensions into nbTranslate rebase
…splay a new language
I just tried it. Very nice!
gets translated to
(when translating English to German with the Jupyter Basics example notebook) |
Thanks @juhasch. That is right. Html structures are also translated! I have added a small fix for that, similar to what is done for maths: remove the structures before conversion, put marks at their original places, and reinsert html after conversion at these places. [I would not be surprised if there exists a switch to instruct google translate to ignore html structures. But I have not be able to find it..] |
I think not always being perfect is OK. The |
neat!
👍 Yes, me too. If you want it to work reliably on everything, I think it'd be possible by extending a marked parser/lexer/renderer, but it'd certainly be a non-trivial amount of work! Regex works perfectly well enough most of the time, particularly as it's a non-destructive operation where the original text is retained. The build failure in the conda_env travis case is a result of the updated jupyter_latex_envs requirment version - you'll need to update the conda-forge/jupyter_latex_envs-feedstock recipe to have the newer version made available from conda-forge. Incidentally, this is the reason I put the conda_recipe environment on travis, so that we'd spot things like this that break the conda build that otherwise I know I'd just miss at least half the time. For updating the feedstock recipe, see conda-forge/jupyter_highlight_selected_word-feedstock#3 as an example. Essentially, unless requirements or imports have changed, you can just update version number & checksum (which I get from pypi.io's download files, to make sure the version I'm referencing is available there, but could equally be done locally on the sdist tar.gz). See the instructions in the readme for an important point - make sure to fork the feedstock & submit a PR, as anything pushed directly to the conda-forge repo gets uploaded to conda-forge channel. Let me know if you have problems 👌 |
I have updated the conda-forge/jupyter_latex_envs-feedstock recipe. The tests for nbTranslate now pass. |
Looks good to me! |
nbTranslate -- helps translating notebooks -- provides multilanguage support
Suggestions for a better name would be very welcome, as well as general improvements directions
This extension
Basically, the extension allows to copy the original cell into a new one for editing and translating. Optionally, the cell source text can be passed through
google translate
and the result inserted in the new cell. Basic markdown structures (e.g. bold, emphasis, lists) are preserved/restored after conversion, to the best extent, but this is not perfect, and usually one has to correct the text and structures afterward. Similarly, equations are extracted before conversion and restored in the result.The extension has been written to play nicely with
An exporter is provided to extract one language from the multilanguage notebook.
See the README here for further details.