Ubuntu – Set text direction in gnome-shell


How can I change the text direction in gnome-shell back and forth between right-to-left and left-to-right?

(Mine is in left-to-right. I have tried changing the language to Chinese (using the "Region and Language" settings widget) which I believe does right-to-left. Upon logging out and back in, the shell still appeared left to right. Do I need to do something else like set a keyboard layout to cause RTL ??).

Best Answer

Gnome as all GTK application, its RTL switch comes from locale definition and it's tight coded. So you have to change to RTL locale/language. If that locale is not installed GUI will be flipped but text/labels/menu will fall-back to the original language (English in most cases) with warning message:

Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.

As I know Chinese is direction independent, I suppose it is configured as LTR. So it is better to look pure RTL locales like Arabic, Hebrew, Persian ...

To change setting for Unity or Gnome Sessions/Desktop

  • To change global settings /etc/default/locale, Example (ar_DZ, Arabic_Algeria):


    Need to logout

  • To change only user setting ~/.pam_environment


    Need to logout

Another way, If you want to flip GUI or switch locale/language for just one application:

  • Open terminal Ctrl+Alt+t
  • Run it with LANG=ar_DZ.UTF-8 or LANGUAGE=ar_DZ.UTF-8, try both of them not all application use same env variable:

    LANGUAGE=ar_DZ.UTF-8 evince
    LANG=ar_DZ.UTF-8 okular

Qt applications have a separated RTL switch -reverse which could be used without language change. Example:

qv4l2 -reverse

Now, If your language is not English and you want to use RTL flipped interface with it. There is a trick, you may test it:

  • Generate new locale as variation of an RTL language, example:

    sudo locale-gen ar_YY.UTF-8
    sudo dpkg-reconfigure locales
  • Copy your language translation (of gettext) files to new locale folder. As example French.

    sudo cp -r /usr/local/share/locale/fr /usr/local/share/locale/ar_YY
  • Not all application put their locales in /usr/local/share/locale/. If you face such case, you may look where all locale files:

    locate /locale/fr