Upstream: Pending, https://gitlab.gnome.org/World/Authenticator/-/merge_requests/160 From 4073b3f3d97f0c4d74a7017da181fb4e41bdef8e Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Wed, 8 Jul 2020 18:08:16 +0200 Subject: [PATCH] Gracefully handle locale.{bind,}textdomain not being available When python is built without gettext support these functions aren't available and as such GTG fails to start without this change. --- src/authenticator.py.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/authenticator.py.in b/src/authenticator.py.in index 1e75e10..2cc371f 100755 --- a/src/authenticator.py.in +++ b/src/authenticator.py.in @@ -35,8 +35,15 @@ from gi.repository import Gio, Handy sys.path.insert(1, '@PYTHON_DIR@') def prepare_locale(): - locale.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@') - locale.textdomain('@GETTEXT_PACKAGE@') + try: + locale.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@') + locale.textdomain('@GETTEXT_PACKAGE@') + except AttributeError as e: + # Python built without gettext support doesn't have bindtextdomain() + # and textdomain() + print("Couldn't bind the gettext translation domain. Some translations" + " won't work.\n{}".format(e)) + gettext.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@') gettext.textdomain('@GETTEXT_PACKAGE@') -- GitLab