I have a python3/Gtk3 application that uses Gtk.Builder, and I’m unable to make it work translated. The texts set from the code (using _(“blah blah”)) are translated, and also the standard buttons in the windows (like a standard button with the “Cancel” text inside), but none of the texts in my .ui files are translated. The odd thing is that this code did work until about two years ago, which suddenly stopped working.
This was the original code:
Gtk.init(sys.argv)
gettext.bindtextdomain(config_data.gettext_domain, config_data.share_locale)
try:
locale.setlocale(locale.LC_ALL, "")
except locale.Error:
pass
locale.bindtextdomain(config_data.gettext_domain, config_data.share_locale)
gettext.textdomain(config_data.gettext_domain)
gettext.install(config_data.gettext_domain, localedir=config_data.share_locale)
Did try with every possible combinations of the previous code. Also tried putting the .mo files directly at /usr/share/locale
instead of using a custom folder, and then do
gettext.install(config_data.gettext_domain)
locale.textdomain(config_data.gettext_domain)
Gtk.init(sys.argv)
but the result is exactly the same: no text from the .ui files is translated, any other text is.
I also tried setting the domain name both using set_translation_domain() method in the Gtk.Builder, and directly in the XML. But again no dice.
How can I fix this?