Friday, February 13, 2009

Awn-Extras Translations

There hasn't been much in Awn-Extras translations: Only 32 strings, all from mail, that weren't imported into awn-extras and wouldn't work even if they were. I uploaded a new template to Launchpad that includes 273 strings from all the applets that at least use the gettext functions. It's been approved, but (as of writing) it hasn't yet been imported. There's also a new file in libawn-extras, 'defs', that tells the prefix and the gettext directory:
>>> from awn.extras import defs
>>> defs.PREFIX
This way all the translations are/will be in a single place, and translating will be much easier. To-do now supports translations, and mail will be able to when the new template is imported. The template is created by using 'xgettext'. This is what I ran to get the template:
xgettext src/*/*.py src/*/*.c --keyword=_ -o po/messages.pot --from-code=utf-8
This is the necessary Python code for making an applet translatable:
import gettext
import locale
from awn.extras import defs

APP = "awn-extras-applets"
gettext.bindtextdomain(APP, defs.GETTEXTDIR)
_ = gettext.gettext
Pass every translatable string to the '_' function. Make sure to put all the text in one long line, as in don't use multiple strings combined by '+'. If you need to use variables, use '%s', etc. This is necessary for xgettext to recognize the string.

I imagine it's mostly the same in C. Some of the applets already have the translation code. When the translations are downloaded from Launchpad, the .po files go in the po folder, the ISO codes are added to the LINGUAS file in po and the ALL_LINGUAS variable in I did some testing with To-do in Spanish, and it works.

Awn Extras Translations

P.S.: If you haven't tried out 0.3.2, what are you waiting for?

Update: The template has been imported!