I need to call setlocale to use gettext from my program. The target system where my program will run is busybox based embedded linux. I compiled busybox with enabled locale support.
This is the testing program code:
#define PACKAGE "hello"
fprintf(stderr, "setlocale: \"%s\"\n", setlocale(LC_CTYPE, ""));
fprintf(stderr, "setlocale: \"%s\"\n", setlocale(LC_MESSAGES, ""));
fprintf(stderr, "bindtextdomain: \"%s\"\n", bindtextdomain(PACKAGE, "locale"));
fprintf(stderr, "textdomain: \"%s\"\n\n", textdomain(PACKAGE));
fprintf(stderr, gettext("Hello, world!\n"));
I created the mo file and put it in locale/xx/LC_MESSAGES/ in the program's directory.
On a normal desktop distro it works: "Hello world" is displayed in the correct translated language according to the environment variable LC_MESSAGES. On the target system it does not work. setlocale works only for C and POSIX. For others, even for en_US, it returns NULL and perror prints:
No such file or directory
Of course gettext then always returns only the original version of text.
I noticed it does not work also on Mepis linux on my desktop PC, although I have the locale packages installed. So I think this is probably not related to busybox/embedded linux
What I am supposed to do to make it work?