site  contact  subhomenews

Geany mysterious Chinese behaviour

September 16, 2024 — BarryK

I used MoManager to create Simplified Chinese zh_CN.UTF-8 translations for /usr/bin/quicksetup, using MoManager's automatic translation feature. The result is in Easy 6.3. However, there is something weird with geany text editor...

A quicksetup.pot file is created like this:

# cp /usr/bin/quicksetup quicksetup.sh
# xgettext -o quicksetup.pot --no-wrap quicksetup.sh

The automatic translations are applied to quicksetup.pot and it becomes quicksetup.po and the latter is then opened in geany for review:

img1

The translations are Chinese characters, and under the Document menu the filetype is UTF-8; yet something weird is displayed instead of the Chinese characters.

Now, take that .po file, convert it to .mo binary format, then back to .po:

img2

...now geany displays the Chinese characters correctly! Including the "Quick Setup":

img3

For the record, here is how I converted po -> mo -> po:

# msgfmt --check --output-file=quicksetup3.mo quicksetup1.po
# msgunfmt --no-wrap quicksetup3.mo > quicksetup3.po

Well, I discovered that it is the comments at the beginning of quicksetup1.po that cause the problem; deleted them and quicksetup1.po displayed correctly in geany.

I have put a fix into MoManager, but left puzzled with geany's behaviour.

EDIT:
It turns out I was barking up the wrong tree. The quicksetup.po file had an invalid UTF-8 sequence on line 123, and this caused the entire file not to display the Chinese characters. Weird. I fixed it by using 'iconv' utility to cleanup the file. This removes the invalid UTF-8 (inserted about line 1077 in /usr/local/momanager/momanager):

    mv -f /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/orig1.po
iconv -f utf-8 -t utf-8 -c -o /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/orig1.po
LANG=C defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po

That fixed it.     

Tags: easy