Coder Social home page Coder Social logo

jupyter-notebook-azure-translator's Introduction

Jupyter-Notebook-Azure-Translator

Contains Python Script to automatically translate the .pot and .json files necessary for adding other languages.

NOTES:

The code to generate the .json file should de commented out, you need to generate it with the command below in step 13.

Requirements

  • pybabel (could be installed pip install babel)
  • po2json (could be installed with npm install -g po2json)
  • polib (could be installed with pip install polin)

Steps

  1. Clone this repo to your pc

  2. Obtain an API key from Azure for basic translations. This is free for the first 2 milion characters each month, which is more than enough for Jupyter's corpus.

  3. Fill in the Azure key in the main file and change the language to your language.

  4. Run main and wait.

  5. Change files from .pot to .po.

  6. Go to your local Jupyter Notebook fork/repo

  7. Open a terminal window and in the notebook folder and do the following

    cd notebook/i18n/

  8. Find out how the browser accepts your language as a header.

    1. Open a notebook in Google Chrome
    2. inspect page
    3. Go to network
    4. Reload the page
    5. Click on tree in list
    6. Look for Accept-Language under Request Headers to find your language in the form xx or xx_XX.
  9. Add your language in the file nbjs.json under supported languages.

  10. In terminal do: mkdir xx or mkdir xx_XX.

  11. cd xx or cd xx_XX.

  12. mkdir LC_MESSAGES

  13. cd LC_MESSAGES

  14. Copy the .po files to this folder.

  15. Do the following commands in the terminal at the folder notebook/i18n from step 6 where ${LANG} is your xx or xx_XX:

pybabel compile -D notebook -f -l ${LANG} -i ${LANG}/LC_MESSAGES/notebook.po -o ${LANG}/LC_MESSAGES/notebook.mo
pybabel compile -D nbui -f -l ${LANG} -i ${LANG}/LC_MESSAGES/nbui.po -o ${LANG}/LC_MESSAGES/nbui.mo
po2json -p -F -f jed1.x -d nbjs ${LANG}/LC_MESSAGES/nbjs.po ${LANG}/LC_MESSAGES/nbjs.json
  1. Done

Testing

  1. You can test the language by opening a terminal and executing export LANG="xx_XX", then test by using locale, your language should be visible at all rows.
  2. Open Jupyter Notebook as usual with the command jupyter notebook.

jupyter-notebook-azure-translator's People

Contributors

berendjan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.