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

Work on loading UI translations #2969

Merged
merged 8 commits into from Oct 31, 2017

Conversation

Projects
None yet
4 participants
@takluyver
Copy link
Member

takluyver commented Oct 23, 2017

To test: set zh-CN to the most preferred language in browser preferences, then launch the notebook with the LANG environment variable set, i.e. LANG=zh_CN jupyter notebook.

screenshot from 2017-10-23 16-01-42

  • Only transfers translations for languages the user wants.
  • (For strings used in JS) can handle multiple fallbacks - e.g. an Afrikaans speaker could request Afrikaans > Dutch > English, and get each translation in the best available language.

Writing the translation JSON into the template and storing it as a JS global seems a bit ugly, but it ensures that the data is there before any Javascript strings are used, without either bundling data for all languages into the JS bundle, or trying to do clever things with requirejs.

The biggest thing that I'm not happy about is that the language for the JS is determined by the browser, and the language for the template strings by an environment variable in the server. If you only set one, you see half the strings translated, with no obvious reason for the difference. Using the browser header seems better, and it allows for multiple fallbacks, but there isn't an obvious way to use that with jinja2.ext.i18n.

@takluyver takluyver added this to the 5.3 milestone Oct 23, 2017

@takluyver

This comment has been minimized.

Copy link
Member Author

takluyver commented Oct 24, 2017

The remaining failure on Appveyor appears to be an unrelated problem with installing nbconvert from conda-forge.

@takluyver takluyver referenced this pull request Oct 24, 2017

Closed

Add Chinese translation #2789

@JocelynDelalande

This comment has been minimized.

Copy link
Contributor

JocelynDelalande commented Oct 25, 2017

To test: set zh-CN to the most preferred language in browser preferences, then launch the notebook with the LANG environment variable set, i.e. LANG=zh_CN jupyter notebook.

Just tested, it does work. Thanks :-)

Note : there is no fallback within a same lang (maybe this is normal behavior) : if I set browser lang to zh, it will never load the zh-CN translation.

@takluyver

This comment has been minimized.

Copy link
Member Author

takluyver commented Oct 25, 2017

Yeah, I think we should probably rename zh_CN to just zh, and introduce an automatic fallback when loading so that if you specify zh_CN, it will use zh as well. But I think those can be in future PRs: I just wanted to get the translations working first.

@gnestor

This comment has been minimized.

Copy link
Contributor

gnestor commented Oct 27, 2017

Great work, @takluyver!! I tried testing and I'm seeing the translations that depend on the browser's language (working in both Chrome and Firefox) but I'm not seeing the translations that depend on the environment variables. I'm using LANG=zh_CN jupyter notebook to run the notebook server... 🤔

@takluyver

This comment has been minimized.

Copy link
Member Author

takluyver commented Oct 31, 2017

I'm not sure what's going on there - maybe there are other environment variables besides LANG that affect it? I'm inclined to get this merged and keep iterating.

@takluyver takluyver closed this Oct 31, 2017

@takluyver takluyver reopened this Oct 31, 2017

@gnestor

This comment has been minimized.

Copy link
Contributor

gnestor commented Oct 31, 2017

Ok let's do it 👍

@gnestor gnestor merged commit e7f69cc into jupyter:master Oct 31, 2017

4 checks passed

codecov/patch 69.35% of diff hit (target 0%)
Details
codecov/project 78.97% (-0.05%) compared to 513709b
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@hikui

This comment has been minimized.

Copy link

hikui commented Aug 11, 2018

Hi @takluyver, the translation doesn't work in the release version. I noticed that .mo and nbjs.json files are gitignored and there's no corresponding compiling process in the setup.py?

I had to manually follow the README and compiled my own version of end files to make the translation work. Perhaps we should keep .mo and nbjs.json files?

@takluyver

This comment has been minimized.

Copy link
Member Author

takluyver commented Aug 11, 2018

There's an issue for someone to integrate the steps to build the translations: #3102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.