translations setup howto?
Mike Rooney
mrooney at ubuntu.com
Mon Jul 27 20:28:16 BST 2009
On Mon, Jul 27, 2009 at 7:00 AM, Dustin Kirkland<kirkland at canonical.com> wrote:
> Howdy-
>
> I am looking for a somewhat comprehensive guide on how to generically
> i18n a project/package, (specifically, ecryptfs-utils).
>
> I know that I need varying degrees of:
> * gettext, xgettext calls in the shell, python, and C code
> * a po directory with some stuff in it
> * hooks in the build system
> * rules in the make file
> * some setup in Launchpad, several rounds of review, eventually
> (hopefully) this bit will be "approved" by the powers that be.
>
> I've crudely configured this in other packages (see: byobu) by emulating
> bits and pieces of code from the archive. But I feel like there should
> be a bit more "science" here, as far as internationalizing a package or
> project goes. A step by step guide would be nice, from the perspective
> of a developer and maintainer. Something like:
>
> 1) Comprehensively go through your code. Prime your setup with (e.g.):
> * Python:
> gettext.bindtextdomain(PKG, SHARE+'/po')
> gettext.textdomain(PKG)
> _ = gettext.gettext
> * Shell:
> TEXTDOMAIN="$PKG"
> ...
>
> 2) Replacing string printing with (e.g.):
> * Shell: xgettext
> echo `gettext "Select a screen profile: "`
> * Python: gettext.gettext
> _("Toggle status notifications")
>
> 3) Add support in your build system by doing ... (?). Edit your
> debian/rules accordingly (e.g.)
>
> 4) Setup translations in Launchpad by doing (a, b, c)
>
> 5) Pull the translations back into your project by doing (?)
>
> 6) Test the setup by (?) installing some other language pack and
> baffling yourself with a foreign tongue :-)
>
> Some pointers would be appreciated.
Hi Dustin, I'd be happy to help you out with this if you need. I gave
an OpenWeek talk on this previously which you may find useful:
https://wiki.ubuntu.com/MeetingLogs/openweekintrepid/LPTranslateInternational
. I also have a little python file localization.py
http://bazaar.launchpad.net/~mrooney/wxbanker/trunk/annotate/head:/localization.py
which you can just import from any file in which you'd like to
localize and everything is set for you (just change your app name to
match your template file name).
Once everything is good, I've also got
http://bazaar.launchpad.net/~mrooney/wxbanker/trunk/annotate/head:/templater.py
which will create a template for you from the files in the current
directory and put it in a place Launchpad recognizes, so when you
commit the template LP will automatically notice and import it for
translation.
Testing isn't too hard either. Here's a test I have to make sure a
currency can localize:
def testCommaDecimalSeparater(self):
loc = "fr_FR.utf8"
self.assertEqual(locale.setlocale(locale.LC_ALL, loc), loc)
self.assertEqual(c.CurrencyList[0]().float2str(1), "1,00 €")
of course now my tests depend on having other locales installed but I
think that is fine, these things need to be tested.
Launchpad makes some of the stuff in my aforementioned talk easier now
(such as auto-importing templates) and some of it could probably be
updated. Maybe that talk should go in a wiki page about the subject
and those files could become a small helper library. Or maybe such
things already exist.
Does any of that help?
--
Michael Rooney
mrooney at ubuntu.com
More information about the ubuntu-devel
mailing list