setlocale() returns NULL
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: Code:
#include <libintl.h> 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? |
Each locale is a separate file, you have to have the file installed in
/usr/lib/nls/loc/locales From the shell Code:
locale -a |
Sorry for late reply... thank you for helping me. "locale -a" showed me what was wrong: I indeed did not have any locales installed but C and POSIX.
All locales take a lot of space and I cannot afford that. It took me a while before I figured out exactly which files I need and which not. It turned out the only file I really need is /usr/lib/locale/locale-archive. Even this one alone is enormous so I regenerated only the needed locales with locale-gen. |
All times are GMT -5. The time now is 08:04 PM. |