tags:

views:

34

answers:

2

Is there a way to find out the default language of a Linux system from C? Is there a POSIX API for this? E.g. I'd like to have a string in human readable format, i.e. "German" or "Deutsch" on a German system, "French" or "Francais" on a French system etc. Is there something like this?

Thanks!

+1  A: 

Usually, the LANG environment variable contains that information in the format like "de_DE.UTF-8".

You can retrieve it using the getenv function.

EDIT:

For more sophisticated internationalization, you might want to look into gettext.

cypheon
A: 

Have a look at getenv and setenv in relation to the environment variables LANGUAGE etc.

This has to do with locales.

http://billposer.org/Software/NumbersAndLocales.html

Be sure to note the different meanings of all the variables. There are overrides through LC_ALL etc.

data