GUI translations fail when loaded from a custom directory
@tobias47n9e
Submitted by Tobias Schönberg Assigned to gtk..@..tk.org
Link to original bug (#753991)
Description
When trying to load the GUI translations in Python under Windows:
if sys.platform.startswith('win'): if os.getenv('LANG') is None: lang, enc = locale.getdefaultlocale() os.environ['LANG'] = lang
import ctypes
LIB_INTL = abspath(join(WHERE_AM_I, "../gnome/libintl-8.dll"))
libintl = ctypes.cdll.LoadLibrary(LIB_INTL)
lc = locale.setlocale(locale.LC_ALL, "")
btd = libintl.bindtextdomain(APP, LOCALE_DIR)
libintl.bind_textdomain_codeset(APP, "UTF-8")
a subsequent call to translate the GUI will fail (silently!):
builder = Gtk.Builder()
builder.set_translation_domain(APP)
This is probably a bug in g_dgettext, and Glib.dgettext(APP, "") should have a return value.
A workaround for this bug is to place the mo-files into (for German for example): /gnome/share/locale/de/LC_MESSAGES/myapp.mo
I have an example program here where I will inform about the bug and the workaround: https://github.com/tobias47n9e/pygobject-locale
Version: 3.22.x