[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: language support




On Monday 18 March 2002 09:49, capmikee@home.martnet.com wrote:
> On Sun, Mar 17, 2002 at 04:07:45PM -0500, Ronen Tzur wrote:
> > On Friday 15 March 2002 12:23, capmikee@home.martnet.com wrote:
> > > I envision a config file or files for theme/language containing all the
> > > messages to be displayed. To add a language, you just add the messages
> > > to the config file(s). No more hardcoded text!
> >
> > Have you considered using GNU gettext for the job?
>
> Thanks for the suggestion- I'm afraid I don't know what gettext
> is. Can you tell me more about it?

Sure.   The gettext library is a GNU package for message translation.  The 
info page says these are the tasks it handles:

   * locate the external data file with the appropriate translations.
   * load the data and make it possible to address the messages
   * map a given key to the translated message

In the program, you use strings of the form _("English String") instead of 
plain "English String".   The "_" magic is a simple macro that invokes 
gettext("English String").  gettext takes the "English String" as the key, 
and brings back a translated string from the external data files.

If you've ever seen packages with a po/ subdirectory containing *.po and *.gmo 
files, these are the external data files for use by gettext.

There is no direct support for parameteric strings like %c and %o that you 
described in your initial post, however gettext does support %s and %d.  Thus 
it seems the same result can be achieved indirectly:  first translating the 
string for %o, and then passing it as a parameter for the output string, 
containing a %s at the proper position.

That's it in a nutshell, and pretty much covers what I know about it at the 
moment.  ;)