views:

282

answers:

1

I'm trying to grok gettext.

Here's how I think it works -

First you use some sort of po editor and tell it to scan a directory for your application, create these ".po" files, the application makes a po file for each file scanned which contains a string in a programming language, then compile them to binary mo files, to which gettext parses, and you call a method using a high level API such as Zend_Translate and specify you want to use gettext, it can be setup to cache translations and it just returns those.

The part I'm really unclear about is how the editing of po files is done really, it's manual - right? Then when the compilation is done of course the application relies on the binary mo files.

And if someone could provide useful linux applications for editing .po files I'd be grateful.

+3  A: 

The tutorial on NLS using GNU gettext should help you understand the process.

As for editing .po files, there's at least two applications (apart from vi :-): gtranslator and poedit.

Gonzalo
Do you use any vim specific plugins, or are none really needed?
meder
I've never used a plugin for vim, but there's something at http://vim.sourceforge.net/scripts/script.php?script_id=695
Gonzalo
I took a read and I might have missed some information, but: 1. Say we're dealing with a python/php web app, what's a typical local to store the po/mo files? Is there a standard directory I can use? 2. Do you use `xgettext` to extract the strings from source code? I think I got most of that information, but if someone could provide a lengthy dumbed-down and less technical explanation and throw in practical real-world tips that'd be great.
meder
Usually you set LOCALEDIR to $PREFIX/share/locale (prefix could be /usr, /usr/local, ...) then for ecah language the files will be in, say, fr/LC_MESSAGES/yourappname.mo. When extracting strings, I go with xgettext. Didn't bother looking for something else when xgettext does what I need.
Gonzalo
Ok one last thing - say you have around ~100 or so files and 50 of them have strings that need to be i18n'd. It doesn't concatenate them all into one .mo file, does it? I was curious since you typed `yourappname.mo`.
meder
All the strings will be in the same .mo and there will be one different .mo per language (ie, en/yourappname.mo, es/yourappname.mo, fr/yourappname.mo and so on).
Gonzalo