Looking for people's experience with po files.
Derek Atkins
warlord at MIT.EDU
Wed Sep 10 11:26:41 EDT 2008
Hi,
"Steven W. Orr" <steveo at syslang.net> writes:
> I understand the purpose of po files but I've never used it. I'm currently
> working on a bash script that's ~10k lines long. It needs to support
> multiple languages and right now we have a set of .lang files that just
> define duplicate variables. e.g.
>
> Filename Content
> lang/English symbol1=Hello
> lang/German symbol1='Guten Tag'
>
> I'm thinking there's gotta be something better. Are po files inappropriate
> for this? Anyone?
A po file is a single language mapping file. So you need multiple
po files, one file per language. Then using gettext() you can
translate from English to whatever foreign language you want based
on the setlocale() language setting.
So in your code you would have something like:
printf(gettext("Hello, %s, you have %d messages waiting.\n"), name, msgs);
and then your po file would contain the mapping of this string to the
language specific translations. For example es.po would contain:
#: ../src/foo.c:244
msgid "Hello, %s, you have %d messages waiting.\n"
msgstr "Hola %s, usted tiene esperar de %d mensajes.\n"
Note that I don't know how well this would work in a bash script,
but I think there is a gettext(1) that you can use.
-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnhlug-discuss
mailing list