Skip to content
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

Pull request i18n #2804

Merged
merged 10 commits into from
Oct 2, 2017
Merged

Pull request i18n #2804

merged 10 commits into from
Oct 2, 2017

Conversation

jianzi123
Copy link
Contributor

add translated files in Chinese.

@takluyver takluyver added this to the 5.2 milestone Aug 25, 2017
@takluyver
Copy link
Member

Awesome, thanks! @JCEmmons can you take a look to see if this is arranged as you'd expect? Should the .mo files be checked in, or should we be generating those at build time?

We're just about to release notebook 5.1, so it will be a few days before we can merge this, but hopefully it can go in soon after the release.

@jianzi123
Copy link
Contributor Author

Except adding the translated files, if something else is needed, please let me know, haha.

@JCEmmons
Copy link
Contributor

JCEmmons commented Sep 5, 2017 via email

@takluyver
Copy link
Member

Thanks for your patience - 5.1 is out now, so we can come back to this.

I think this PR should only need to add three files:

notebook/i18n/zh-CN/LC_MESSAGES/nbjs.po
notebook/i18n/zh-CN/LC_MESSAGES/notebook.po
notebook/i18n/zh-CN/LC_MESSAGES/nbui.po

The .mo and .json files should be generated at build time, so they shouldn't be stored in git. And we shouldn't need the zh_CN.UTF-8 folder: everything should be UTF-8 anyway, and the code should take care of loading it correctly.

Even if this doesn't actually work at the moment, having a set of translations to work with will be really useful for us to figure out the infrastructure to make it work.

@JCEmmons
Copy link
Contributor

JCEmmons commented Sep 15, 2017 via email

@gnestor
Copy link
Contributor

gnestor commented Sep 16, 2017

I'm trying to test this with no luck. I tried the following:

  • Based on @JCEmmons suggestion, I renamed the language from "zh_CN" to "zh"
  • According to the i18n docs in this repo, I added "zh" to supported_languages in nbjs.json
  • I added "Chinese [zh]" to the languages in Firefox and moved it to the top of the list
  • I ran the notebook server with LANG=zh jupyter notebook --no-browser

@jianzi123 Have you had any luck in testing this? @JCEmmons?

@takluyver
Copy link
Member

I don't think the code to load translations is actually in place. We were having some trouble working out how to load the translations early enough, but without requesting all languages.

@jianzi123
Copy link
Contributor Author

jianzi123 commented Sep 18, 2017

@gnestor
I took a few days off to go home, and sorry for replying this so late...

  • ​First, check the local env using locale, make sure there are some languages supported

LANG=zh_CN.UTF-8

  • put zh-CN to nbjs.json... this is not the same as language above while it is related to path i18n/zh-CN

  • Then, make sure there are not 404 in your log, some logs show that there are not files like nbjs.json,

  • make sure in code

    1. add_ /i18n/LANG/... to url path;

    2. add lang para into gettext.translation() function in notebook/notebookapp.py;

@takluyver Asynchronous loading of language files does have some latency, in my project I replace some words in code...

@JCEmmons
Copy link
Contributor

JCEmmons commented Sep 18, 2017 via email

@JCEmmons
Copy link
Contributor

I was able to have some level of success with these translations. But there are some things that weren't quite right..... Here's what I did:

1). The translated files are really .po, not .pot ( although the format is the same ), so I renamed them.
2). Put the translated notebook.po and nbui.po into notebook/i18n/zh-CN/LC_MESSAGES.
3). Run pybabel compile to create Chinese notebook.mo and nbui.mo in notebook/i18n/zh-CN/LC_MESSAGES per the instructions.
4). Run po2json to create Chinese nbjs.json in notebook/i18n/zh-CN/LC_MESSAGES
5). Update notebook/i18n/nbjs.json to add "zh-CN" to the list of supported languages.
6). Update notebook/static/base/js/i18nload.js per the instructions in the comment:

     // These are only here so that the optimizer knows which ones we MIGHT load.
 // We will actually only load the ones we need. There should be one entry
 // here for each language you want to support.
 // For example, for German....
 "json!base/../../i18n/zh-CN/LC_MESSAGES/nbjs.json"

7). Regenerate the javascript with "setup.py css js"
8). Set your language to zh-CN and your browser default to zh-cn.
Run jupyter notebook.....

In case you're wondering, the reason we're using zh-CN instead of just zh is that moment doesn't have a "zh" locale, only "zh-cn" and "zh-tw", so the date stuff won't come out right if you try to use just "zh".
image

Some things to be noted:

1). There are a number of places where the English has changed since my original drop, so in order to completely do this right, you would need to update the English using pybabel extract in the instructions, and then translate the updated files.

2). There are some places where the translations were incomplete or missing items.

But overall, these files seem to work OK and produce reasonable amounts of Chinese.

@jianzi123
Copy link
Contributor Author

Thank you for testing the files
and some words should add i18n codes include the plug-in and others...

I will try to update some files...

@takluyver
Copy link
Member

I've cleaned up the files in this PR a bit. Does the structure now look about right? If so, I suggest that we merge this and use it as a base to work out how to load the necessary translations for the UI.

If someone other than me hits the button, I'd suggest using the 'squash and merge' option for this PR so that the binary .mo files are not in our repo history.

@jianzi123
Copy link
Contributor Author

I think that we could merge this and fix the details in some version...

@gnestor gnestor merged commit de09c12 into jupyter:master Oct 2, 2017
@gnestor
Copy link
Contributor

gnestor commented Oct 2, 2017

Thanks @takluyver and @jianzi123!!

@gnestor gnestor mentioned this pull request Oct 2, 2017
@gnestor gnestor modified the milestone: 5.2 Oct 13, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants