Re: language support
From: Roger Leigh (${roger}_at_invalid.whinlatter.uklinux.net.invalid)
Date: 10/09/04
- Next message: Larry I Smith: "Re: Creating Class Library Question"
- Previous message: Gregory L. Hansen: "Re: Fortran vs. C (was Re: Ken & Klaus.)"
- In reply to: Ask: "language support"
- Next in thread: LEE Sau Dan: "Re: language support"
- Reply: LEE Sau Dan: "Re: language support"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 09 Oct 2004 01:54:03 +0100
ask8y@yahoo.com (Ask) writes:
> I want to know how language support works in LInux.
> Let assume I wrote a program, working in English version Linux.
> Now I want port it inot a foreign language, say Chinese, and assume I
> know the language well enough, from programming prespective, what are
> steps I have to follow to get it ported?
You need to use gettext. This can be done roughly like so:
- Add gettext infrastructure (autoconf/automake bits)
- Add init code to your program or library initialisation routine
to get the locale and load the message catalogues.
- Mark translatable strings in your source using _() and N_()
and manually translate with gettext() where required.
- Run xgettext to pull out the translatable strings
- Translate the strings
The main part is translating stuff like this:
printf("Processing foo: %d-%s\n", foo, bar);
to this:
printf(_("Processing foo: %d-%s\n"), foo, bar);
This expands the string literal to gettext("Processing foo: %d-%s\n")
which returns the translated version of the string. It's pretty neat.
The _() is also used by xgettext to identify which strings need
translation.
> You might find dificult ot explain all to someone who does not know
> anything about it like, you could point me to some introduction
> material.
This is documented in the GNU gettext and GNU libc manuals. Lots of
programs use it, so there's a lot of example code out there. The
gettext manual has instructions for adding gettext support.
> Also is there a tool that helps this?
gettextize. Make a backup of your source tree before you run it--it
thinks it's too clever by half, and broke my carefully crafted
configure.ac and Makefile.ams. This should add the necessary
infrastructure, but do check exactly what it's done to correct any
damage.
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
- Next message: Larry I Smith: "Re: Creating Class Library Question"
- Previous message: Gregory L. Hansen: "Re: Fortran vs. C (was Re: Ken & Klaus.)"
- In reply to: Ask: "language support"
- Next in thread: LEE Sau Dan: "Re: language support"
- Reply: LEE Sau Dan: "Re: language support"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|