Contains Python Script to automatically translate the .pot and .json files necessary for adding other languages.
The code to generate the .json
file should de commented out, you need to generate it with the command below in step 13.
- pybabel (could be installed
pip install babel
) - po2json (could be installed with
npm install -g po2json
) - polib (could be installed with
pip install polin
)
-
Clone this repo to your pc
-
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.
-
Fill in the Azure key in the main file and change the language to your language.
-
Run main and wait.
-
Change files from
.pot
to.po
. -
Go to your local Jupyter Notebook fork/repo
-
Open a terminal window and in the notebook folder and do the following
cd notebook/i18n/
-
Find out how the browser accepts your language as a header.
- Open a notebook in Google Chrome
- inspect page
- Go to network
- Reload the page
- Click on tree in list
- Look for
Accept-Language
underRequest Headers
to find your language in the form xx or xx_XX.
-
Add your language in the file
nbjs.json
under supported languages. -
In terminal do:
mkdir xx
ormkdir xx_XX
. -
cd xx
orcd xx_XX.
-
mkdir LC_MESSAGES
-
cd LC_MESSAGES
-
Copy the
.po
files to this folder. -
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
- Done
- You can test the language by opening a terminal and executing
export LANG="xx_XX"
, then test by usinglocale
, your language should be visible at all rows. - Open Jupyter Notebook as usual with the command
jupyter notebook
.