geany / geany-plugins

The combined Geany Plugins collection
http://plugins.geany.org/
594 stars 266 forks source link

GeanyPy: plugins has no translation strings #272

Open scriptum opened 9 years ago

scriptum commented 9 years ago

While GeanyPy itself translatable, plugins included in it have no translation strings. It's easy to localize python:

import gettext
_ = lambda x: gettext.ldgettext("geany-plugins", x)

or

from gettext import gettext as _

Upd: parts of GeanyPy written in Python aren't translatable too:

        lbl = gtk.Label("Choose plugins to load or unload:")
frlan commented 9 years ago

Would this approach need any changes on update-po procedure?

b4n commented 8 years ago

@frlan no, it would work just fine as is, just listing python files in POTFILES.in and marking strings with _()

I gave this a quick shot, and the extraction process works fine, but I can't seem to get the translations from Python, as it makes it crash somehow:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/tmp/_install_gtk2/lib/geany/geanypy/geany/__init__.py", line 20, in <module>
    import manager
  File "/tmp/_install_gtk2/lib/geany/geanypy/geany/manager.py", line 7, in <module>
    t = gettext.translation('geany-plugins', '/tmp/_install_gtk2/share/locale')
  File "/usr/lib/python2.7/gettext.py", line 481, in translation
    t = _translations.setdefault(key, class_(fp))
  File "/usr/lib/python2.7/gettext.py", line 182, in __init__
    self._parse(fp)
  File "/usr/lib/python2.7/gettext.py", line 317, in _parse
    plural = v[1].split('plural=')[1]
IndexError: list index out of range

either using the recommend

import gettext
t = gettext.translation('geany-plugins', '...')
_ = t.gettext

or the one here after binding the textdomain with gettext.bindtextdomain().