setlocale doesn't change the language. Why?
Hi.
I'm running Debian Squezze on a small AMD Geode based embedded PC. I need
to use the gettext library independend from the system wide language
settings to toggle the language for strings only.
On my PC, the test runs within a chroot environment als expected. On the
embedded PC, it doesn't switch the language with setlocale().
Please can some help me?
Here's the code snippet I use.
#define PACKAGE "sample2"
#define _(String) gettext (String)
int main()
{
printf("Current LOCALE: '%s'\n",setlocale(LC_ALL,0));
bindtextdomain(PACKAGE,"./locale");
textdomain(PACKAGE);
printf("Switch to 'en'\n");
setlocale(LC_MESSAGES,"en_EN.UTF8");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));
printf("Switch to 'de'\n");
setlocale(LC_MESSAGES,"de_DE");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));
printf("Switch to 'de.utf8'\n");
setlocale(LC_MESSAGES,"de_DE.UTF8");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));
return 0;
}
The output in the chroot is:
$ ./sample2
Current LOCALE: 'C'
Switch to 'en'
New LOCALE: 'C'
Hello World
Switch to 'de'
New LOCALE: 'C'
Hello World
Switch to 'de.utf8'
New LOCALE: 'de_DE.UTF8'
Hallo Welt
And on the embedded PC:
# ./sample2
Current LOCALE: 'C'
Switch to 'en'
New LOCALE: 'C'
Hello World
Switch to 'de'
New LOCALE: 'C'
Hello World
Switch to 'de.utf8'
New LOCALE: 'C'
Hello World
Reply to: