Re: Translate printf("Hallo")
On 29 September 2013 23:41, Beco <rcb@beco.cc> wrote:
> On 29 September 2013 23:35, Martin Eberhard Schauer wrote:
>>> Please, what would be the correct way to translate printf messages (in
>>> a C program) into some other languages?
>>
>> You will have to learn about gettext and prepare your program for it.
Hi guys,
Do gettext assume the original program is written in english?
I'm testing this example here:
http://oriya.sarovar.org/docs/gettext_single.html
What if my program source has messages in other language?
Example, I create this program:
================> hallowelt.c <================
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
setlocale( LC_ALL, "" );
bindtextdomain( "hallo", "~/tmp/locale" );
textdomain( "hallo" );
printf( gettext( "Hallo, welt!\n" ) );
exit(0);
}
$gcc hallowelt.c -o hallowelt
and I got my binary:
================> hallowelt <================
$xgettext -d hallo -s -o hallowelt.pot hallowelt.c
and I got my template
================> hallowelt.pot <================
I created a "po" and edited it to have my translation TO ENGLISH.
$msginit -l en_US -o en_US-hallowelt.po -i hallowelt.pot
================> en_US-hallowelt.po <================
Compiled it
$msgfmt -c -v -o hallo.mo en_US-hallowelt.po
and got
================> hallo.mo <================
Now I moved it to the correct location.
$mv hallo.mo ~/tmp/locale/en/LC_MESSAGES
The problem now is that I can only run it in english!
How can I see it in the original form?
Thanks,
Beco.
--
Dr Beco
A.I. researcher
"Sometimes the heart sees what is invisible to the eye." (H. Jackson Brown Jr.)
Reply to: