Search code examples
pythonlinuxgtk3

Set language of GTK Buttons to a different language - Linux - Python


How can I set the default language of the Gtk3 Stock Buttons to another language?

I tried:

sudo apt-get install language-pack-en language-pack-gnome-en

But:

import locale
from pprint import pprint

pprint(locale.getlocale(locale.LC_ALL))
locale.setlocale(locale.LC_ALL, 'en_EN.utf8')

response:

('de_DE', 'UTF-8')
Traceback (most recent call last):
  File "tp_tools.py", line 41, in <module>
    locale.setlocale(locale.LC_ALL, 'en_EN.utf8')
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Working on Linux Mint 18 with Python 2.7 and Gtk3


Solution

  • en_EN.utf8 and also en_EN is no valid locale (contrary to de_DE). You can list your installed locales with locale -a in your shell.

    A correct locale would be for example en_US or en_GB. And a correct instruction would be locale.setlocale(locale.LC_ALL, 'en_US').