Search code examples
pythonpython-3.xpygobject

Localization of PyGObject GUI using Gettext


I have directory, which is called locale and subdirectories with languages (ru, ua, de etc.)

My Python script is translated:

from libs.gettext_windows import gettext_windows

scriptdir = os.path.abspath(os.path.dirname(__file__))  # directory with this script
# translating strings in _()
lang = gettext_windows.get_language()
translation = gettext.translation("vk_stats", localedir="{}/locale".format(scriptdir), languages=lang)
_ = translation.gettext

How I can localize my GUI (in development)?

vk_stats.ui

I prefer to use Glade.


Solution

  • See this answer:

    https://stackoverflow.com/a/10540744/439494

    The procedure is very well explained there.

    Also you might need to do this also:

    https://stackoverflow.com/a/8377533/439494