I have a small python program that shows how to do translations of GTK (pygobject) GUIs for Linux and Windows. Everything works in Linux, but in Windows non-ASCII symbols are not rendered in the translation.
I assume that the both the Glade file and the *.mo file are decoded correctly because:
Here is what the interface looks like in the English original:
And the German translation using no environment variable or PANGOCAIRO_BACKEND=win32
:
The German translation using the environment variable PANGOCAIRO_BACKEND=fontconfig
(PANGOCAIRO_BACKEND=fc
). The first label is set to use Calibri using Pango. And that is certainly a font that has "ö", "ä" and "ü" on Windows.
In the console this warning appears for the translation: Pango-Warning **: Invalid UTF-8 string passed to pango_layout_set_text()
.
Some details about getting the translations to work were already discussed here:
The repository:
The installer for Windows:
Is it possible that builder.set_translation_domain("pygibank")
pushes the translations with the wrong encoding? Is it possible to debug this or does anyone know how to fix this?
It looks like you are using Python 2. Python 2 uses ASCII by default, however you can tell it to use Unicode by putting this on your first line.
# -*- coding: utf-8 -*-
This saves you prefixing every string with u
, as suggested below, which you might forget to do, potentially creating bugs.
Alternatively, if you move to Python 3, it uses Unicode by default, so you do not need to do either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With