translations problem
All-In-One PyGI/PyGObject for Windows Installer
Status: Abandoned
Brought to you by:
tumagonx
Maybe this is not a correct place to report this issue, but anyhow it's pygoject and windows specific, so I give it a try.
I'm trying to add Windows support to PyChess and find that gettext translation will work with this code only:
from ctypes import cdll
libintl = cdll.LoadLibrary("libintl-8")
libintl.bindtextdomain(domain, locale_dir)
libintl.bind_textdomain_codeset(domain, 'UTF-8')
(See Havoc latest comment at http://stackoverflow.com/questions/10094335/how-to-bind-a-text-domain-to-a-local-folder-for-gettext-under-gtk3)
This works OK on Python2 but not on Python3. Any idea why?
Hi! I am also having trouble with that (Also using Python3). In this question ( http://stackoverflow.com/questions/32037573/load-gtk-glade-translations-in-windows-using-python-pygobject?lq=1 ) and with some help of the Gnome developers we found out that the mo-files sometimes have to go into "/gnome/share/locale/". Another thing I did wrong in the beginning was to get the path to libintl-8.dll correct. See this repository for a somewhat working example: https://github.com/tobias47n9e/pygobject-locale
But I still have difficulties with the non-ASCII symbols and with rev21 of this package I don't get any GUI translations anymore (just print-statements are translated). See: http://stackoverflow.com/questions/32182159/non-ascii-symbols-in-translation-of-gtk-gui-in-windows-not-working?lq=1
Last edit: Tobias Schönberg 2015-08-24
special note in rev21, I use older intl dll prior to this it has been patched to be able correctly find translations in relative path fashion e.g [intl dll location]\share\locale without help from glib. But I had to revert the dll due to unclear issue here https://sourceforge.net/p/pygobjectwin32/tickets/11/
does replacing it with attached libintl-8.dll fix that?
Also try to set enviroment PANGOCAIRO_BACKEND=win32 if that was rendering issue rather translation issue.
@tumagonx : Is it possible that the attached dll is for 32 bits? Could you attach the 64 bit one too? I will have to look into setting that environment variable.
Sure
With attached .dll python segfaults. In console I see several lines like these:
(python.exe:3312): Gtk-WARNING **: Failed to set text from markup due to error parsing markup: Hiba a(z) 1. sor 26. karakterÚnÚl: ╔rvÚnytele
n UTF-8 kˇdolßs˙ sz÷veg a nÚvben - nem ÚrvÚnyes äJ\xe1tszma adataiö
It doesn't like strings like _("<b>something</b>")
With python2 translatable strings with some markup are OK. Seems gettext+libintl+glade+python3+pygobject on Windows are not friends yet :)
Last edit: Bajusz Tamás 2015-08-26
I get the following warning for each "ö" or similar character in the interface. Printing the translated strings in the Python console still works:
Pango-Warning **: Invalid UTF-8 string passed to pango_layout_set_text()
Do you also use pynsist to package the Python 3-Version?
Tobias, I think our problems are different. Everything is OK if I use PyChess on Windows with Python2. But if I us it with Python3, translations from glade files doesn't work at all. With build 21. nothing happens, and no error message. With attached .dll (and moving .mo files under gnome dir as you suggested) at least I got a segfault and warnings I copyed here.
To package PyChess firs I try to use cx_freeze. Next step will be to choose some installer.
btw. Our startup script is here: https://github.com/pychess/pychess/blob/master/pychess
Thanks for the information.
I think I hijacked your bug report, because at first it was similar. But the UTF-8 stuff seems to be unrelated.
Thanks tumagonx! The translations work with that file, but I still have trouble with the UTF-8 characters (The problem outlined here: http://stackoverflow.com/questions/32182159/non-ascii-symbols-in-translation-of-gtk-gui-in-windows-not-working?lq=1 ). Do you know where I need to set the "PANGOCAIRO_BACKEND=win32" for the pynsist-launcher? The problem might also be that my program is not passing the locale string correctly. I think en_GB should actually be en_BG.UFT-8 for it to work.
I suggest that you set localedir on your own, not relying on libintl. Although originally I patch it to make it easier for windows users :( but I had to revert it for ticket #11. You could use help from glib such get_system_data_dirs or from python argv to build the correct locale path.
PANGOCAIRO_BACKEND=win32 need to be set globally (set it from Windows System Property's Environment Variable) or via command in bat file before loading python, sorry if that's not what you want. This is dillematic, on many case I found fontconfig to be superior in match the right unicode font than the native win32 method, that's why I decide to switch to fontconfig by default.
Regarding your screenshot:
- Could be wrong encodings as you stated
- Could be incorrect font being used (not covering the symbols char)
I now tried using both
PANGOCAIRO_BACKEND=win32
andPANGOCAIRO_BACKEND=fc
and then tried to switch the font of the interface labels. I updated the description here:http://stackoverflow.com/questions/32182159/non-ascii-symbols-in-translation-of-gtk-gui-in-windows-not-working
I also talked to lazka a few days ago and he thought it was a bug in g_dgettext ( https://bugzilla.gnome.org/show_bug.cgi?id=753991 ).
Last edit: Tobias Schönberg 2015-08-26
translation is still not working with the example of the thread opener? using 3.18.2rev8
could someone post a working example of a glade ui file translated?
best wishes
Using 3.18.2rev8 translations from xml(.ui) appear on GUI, but I am facing all the same problems Tobias Schönberg described above.
You can study our problem on hes sample project at https://github.com/tobias47n9e/pygobject-locale
You have to put into comment line at https://github.com/tobias47n9e/pygobject-locale/blob/master/pygibank/pygibank.py#L59 to reproduce the problem.
Last edit: Bajusz Tamás 2016-08-13