Ipython: Jupyter notebook become RTL after upgrade

Created on 14 Jan 2018  ·  34Comments  ·  Source: ipython/ipython

I created python 3.6 environment in miniconda. Jupyter notebook is working now right-to-left .

It is impossible to write code like this.

How can I fix it "

installed packages are:
ipykernel 4.7.0 py36_0 conda-forge ipython 6.2.1 py36_1 conda-forge ipython_genutils 0.2.0 py36_0 conda-forge jupyter_client 5.2.1 py36_0 conda-forge jupyter_core 4.4.0 py_0 conda-forge nbconvert 5.3.1 py_1 conda-forge nbformat 4.4.0 py36_0 conda-forge notebook 5.2.2 py36_1 conda-forge

notebook metadata:
{ "celltoolbar": "Edit Metadata", "kernelspec": { "name": "python3", "display_name": "Python 3", "language": "python" }, "language_info": { "name": "python", "version": "3.6.4", "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python", "file_extension": ".py" } }

Most helpful comment

Press Ctrl-Shift-F to bring up the command palette. Search for 'rtl' and select 'toggle rtl layout'. It should switch around.

If the first language selected in your browser is Arabic or Hebrew, it currently selects RTL by default. CCing @samarsultan in case that needs refining.

All 34 comments

Press Ctrl-Shift-F to bring up the command palette. Search for 'rtl' and select 'toggle rtl layout'. It should switch around.

If the first language selected in your browser is Arabic or Hebrew, it currently selects RTL by default. CCing @samarsultan in case that needs refining.

Thanks @takluyver, however that works only for the current session. Any new notebook will start with the RTL option on again. Additionally, the tree page (http://localhost:8888/tree) is in RTL too...

Is there some global flag to turn off RTL option altogether?

EDIT: OK, I changed the default language of the browser (Chrome) from Hebrew to English, and now everything works.

As far as I know, currently the only way to change it permanently is to change the browser's default language. If there are enough users with Arabic/Hebrew locales who still LTR layout, we should probably make it separately configurable, perhaps by making the existing toggle permanent.

@takluyver hey, my chrome browser is set to english, yet I still having issues with RTL layout.
Is there another possiable solution?

Open up your browser's Javascript console and check navigator.language - that's what our code looks at to decide on RTL.

@takluyver ok great it shows me "he-IL"
so I need to change it? how?

It should be in browser settings somewhere. If there's a list of languages, it probably uses the top one on the list.

I changed it, now english is the first language in the settings. but still navigator.languages display "he-IL". :(
Do you have any idea what to do?

Have you closed the browser and reopened it? Maybe the language settings only affect it when you next start it. If that's not it, no idea...

You can try chrome://settings then go to Advanced settings click on languges then remove arabic languge just like this
untitled

@ibraheemkhazbak Already tried it, still having problems :(

I have the same problem, the jupyter always opens with the rtl toggle and I need to cancel it each time.
my default browser language is English, does someone has an idea what else I can try to solve it?

What version of the notebook package do you have, and what does navigator.language give you in your browser's Javascript console?

I've recently encountered the same problem myself. Finally, the solution was to uninstall Chrome (with iObit Uninstaller - I didn't try a regular Windows uninstall), restart the computer (for good luck) and then re-install Chrome. Works perfectly.

@takluyver My navigator.language is Hebrew although my default language set to English.
I understand now that the problem comes from the browser and not from the Jupyter, so I will fix it using Efrat way.
thanks for the help

@Effrat
I tried this way and still no luck (including resetting).
Other recommendations? anyone?

Same here /:
Is there a way to override in the notebook or command line ?

That worked for me:

  1. removed Hebrew (or Arabic) from Chrome languages (as mentioned before)
  2. deleted browser cached files

@takluyver , thanks! Though I don't think it's a matter of enough users. The rest of the notebook's UI is in English, so no reason of RTL layout regardless of personal habits.

For anyone that using @Effrat solution and it doesn't work:
Make sure when you log in to your google account, don't sync the settings.
Syncing the settings will make jupyter going rtl again

That worked for me:

  1. removed Hebrew (or Arabic) from Chrome languages (as mentioned before)
  2. deleted browser cached files

It is worked for me after clear chrome's browsing data and restart it.

@LiranDan's answer worked for me, however did anyone find a way to sync the account without Jupyter in Chrome recognizing the navigator.language as HE? When I tried with a different browser such as FireFox it works just find and the default language is En. There must be a way to change the default language of the Google account (I already removed Hebrew from the Google account languages and still no good).

EDIT: after playing with the language settings in my account a bit more it appears to be solved and he-IL doesn't exist anymore in my chrome browser.

Managed to solve this for my Windows 10 in the following way.

The only language in Chrome languages was English.
However it kept showing the notebook in RTL no matter what I did.
(You can see the current languages in chrome dev tools window.navigator.languages, it picks the first one)

Eventually, I opened Windows 10 languages screen and re-ordered the languages.
Specifically, I had English first and then Hebrew, so I reordered Hebrew first and then English and then reordered again.

Closing the browser and re-opening it finally worked.

Is there intent/support to change the default behaviour?
RTL for english is useless, and even if the menus are in an RTL language, the notebook contents will still get mangled if they're in english, which 99.9% of notebooks are. So RTL is not useful to almost anyone.

I believe it would be much better to default to LTR regardless of localization, and allow for toggling.

I've long had a suspicion that our logic for switching to RTL is a bit over-eager. But as I don't read any RTL language, I don't count my thoughts for much on the topic.

It's tricky to sample opinion on an issue tracker, because it strongly selects for people who have a problem with the current behaviour. But if someone who's familiar with RTL languages wants to submit a PR to leave the interface LTR by default, I'd be inclined to merge it.

@m2-farzan has opened several PRs against the notebook to improve RTL support. It would be great if another person familiar with RTL languages could take a look and check that they make sense:

As an RTL person (Hebrew) I can confirm that having RTL layout in a development environment is very annoying. I would go even further and say that it is _never_ useful, not even as a non-default option.

The only context in which RTL is useful is when you have complete paragraphs of the RTL language, or when the entire UI is translated (which cannot possibly happen in development environments).

I am currently using Jupyter mainly for analyzing Hebrew text. I would love to be able to print right-aligned text examples here and there, but this has nothing to do with the entire UI.

Here's a screenshot - there's nothing useful in Hebrew here, but you get the period on the wrong end of the sentence, and the path is reversed.
image

Again, no useful information in Hebrew, the In [ ] bullets are on the wrong side, and you get RTL _only_ when it's not helpful. If anything, I'd want the word שלום to be right-aligned, but nothing else.
image

Some editors determine the directionality of a paragraph automatically based on the first characters. Perhaps it would make sense to do something similar for each cell?

@haggaie Jupyter notebook uses CodeMirror as its text editor library. Therefore, the feature of automatically changing the direction of each line based on its first character would need to be implemented in CodeMirror, which is currently an open feature request (https://github.com/codemirror/CodeMirror/issues/4006).

Please note that in Jupyter notebook version >= 6.1 you can use command palette (Ctrl+Shift+P in chrome) to change the direction of a cell or the entire notebook. There you can find two useful commands: toggle current cell ltr/rtl, and toggle notebook ltr/rtl. I've found those commands to be just enough for daily purposes.

P.S.

So if you already know about those commands but you really need automatic changing the direction of each cell, an extension can be developed that uses something like this gist to detect direction and then dynamically set the direction metadata tag of cells. Another (non-recommended) workaround is to try the hacky extension that I'd written in the past (here).

Thanks @m2-farzan. To be honest, I'm mostly satisfied with the toggle rtl layout setting, as I usually work with chrome set to RTL locale while working on fully LTR notebooks. But I agree changing each cell with the settings you mentioned could be helpful.

'Toggle rtl layout' solves the issue, but this is about sane defaults: the current defaults are never correct.
The way this is implemented forces every new hebrew or arabic speaking jupyter user to have a terrible experience until they find this thread.

This is fixed as of jupyter 6.1.0

Was this page helpful?
0 / 5 - 0 ratings