Notebook: Add Chinese translation

Created on 22 Aug 2017  ·  19Comments  ·  Source: jupyter/notebook

do setup.py extract_messages, outputs cmd not found...
I just want to know how to use i18n function...
Thanks.

Most helpful comment

Being able to load the translations into the browser without having to transfer every language. I'm planning to work on it soon.

All 19 comments

See the README here: https://github.com/jupyter/notebook/tree/master/notebook/i18n

The framework is in place, but it's not really being used at present.

@takluyver I make it work... and may push the zh-CN pot to the poject...

@takluyver “setup.py extract_messages” need to get character encoding and ...some script to do other things like mkdir... and i think the most complicated thing is translation...

I don't think the setup.py extract_messages thing has been implemented, it looks like that's something the README is talking about adding in the future.

@JCEmmons someone is trying to use the translation machinery you added :-)

You are correct that setup.py extract_messages is something that I have
not had time to implement. So for the time being you must follow the
manual instructions in the README. Being consumed with other projects, I
doubt whether I would get to it anytime soon, although I would certainly
like to.

Regards,

John C. Emmons
Globalization Architect & Unicode CLDR TC Vice Chairman
IBM Globalization Team
e-mail: [email protected]

From: Thomas Kluyver notifications@github.com
To: jupyter/notebook notebook@noreply.github.com
Cc: John Emmons emmo@us.ibm.com, Mention
mention@noreply.github.com
Date: 08/22/2017 10:28 AM
Subject: Re: [jupyter/notebook] About i18n (#2789)

I don't think the setup.py extract_messages thing has been implemented, it
looks like that's something the README is talking about adding in the
future.
@JCEmmons someone is trying to use the translation machinery you added :-)

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@takluyver i'm sorry to let you be confused about the implementation of setup.py extract_messages , and i think the bable cannnot automatically translate into other languages, and i translate the pot files from English to Chinese in my work... and i wish to push them to the project.
Thanks.

No worries! That matches my understanding - Pybabel is a tool for managing translations, but the actual translation work has to be done by humans.

Do you want to make a pull request? The code can't actually use your translations yet, but it will be good to have some to test with.

i build the project in the development way, and find that before using the internationalization function i we should fix two place:

  1. add_ /i18n/LANG/... to url path;
  2. add lang para into gettext.translation() function in notebook/notebookapp.py;

@takluyver could i make a pull request to add the translated files to some dir...?

Yup. The README says this is where to place them:

After the source material has been translated, you should have 3 PO files with the same base names as the POT files above. Put them in notebook/i18n/${LANG}/LC_MESSAGES, where ${LANG} is the language code for your desired language ( i.e. German = "de", Japanese = "ja", etc. ).

I just merged https://github.com/jupyter/notebook/pull/2804. Thanks for contributing these translations @jianzi123 and thank you for getting things cleaned up and in working order @takluyver.

What do we need to do next in order to actually translate the UI?

I cannot test the translations in current master.

I tried

LANG=zn jupyter notebook

and

LANG=zh_CN.UTF-8 jupyter notebook

(with current master)

but the interface is still in english.

What am i doing wrong ?

There is a still a piece missing to enable the translation in the UI.

@takluyver @JCEmmons Can you explain what that piece is? I will gladly work on it 👍

Being able to load the translations into the browser without having to transfer every language. I'm planning to work on it soon.

2969 is my effort on that front.

The thing that typically gets missed is adding a line to https://github.com/jupyter/notebook/blob/master/notebook/static/base/js/i18nload.js to define which languages you might want to support. I'm pretty sure that the framework will only load those languages that you need, but this is required in order for the translated UI to work properly.

I experimented with that, and it appeared that all the translation strings specified like json!base/../../i18n/de/LC_MESSAGES/nbjs.json were being stuffed into the main.min.js bundle, so it would load all languages (meaning that it would transfer them from the server to the browser).

As such, #2969 gets rid of i18load.js in favour of an approach where the necessary Javascript string translations are added into the page by the template, so they're globally available before the main Javascript runs.

The PR was merged, is there anything else to discuss here?

Yup, this can be closed now. Thanks Damian!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pylang picture pylang  ·  3Comments

mikepqr picture mikepqr  ·  3Comments

cancan101 picture cancan101  ·  3Comments

ehossain1982 picture ehossain1982  ·  3Comments

fonnesbeck picture fonnesbeck  ·  3Comments