Menu

#22 translations problem

1.0
open
nobody
None
2016-08-13
2015-08-01
No

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?

Discussion

  • tumagonx

    tumagonx - 2015-08-24

    Also try to set enviroment PANGOCAIRO_BACKEND=win32 if that was rendering issue rather translation issue.

     
  • Tobias Schönberg

    @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.

     
  • tumagonx

    tumagonx - 2015-08-25

    Sure

     
    • Bajusz Tamás

      Bajusz Tamás - 2015-08-26

      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
      • Tobias Schönberg

        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?

         
        • Bajusz Tamás

          Bajusz Tamás - 2015-08-26

          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

           
          • Tobias Schönberg

            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.

             
  • Tobias Schönberg

    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.

     
  • tumagonx

    tumagonx - 2015-08-25

    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)

     
  • forenjunkie

    forenjunkie - 2016-08-13

    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

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.