Is there a way to learn the default language of a Linux system with C? Is there a POSIX API for this? For instance. I would like to have a string in a readable format, for example, “German” or “German” in the German system “French” or “franc” in the French system, etc. Is there something like this?
Thank!
Typically, an environment variable LANGcontains this information in the format "de_DE.UTF-8".
LANG
You can get it using the function getenv.
getenv
EDIT:
For more complex internationalization, you may need to learn gettext .
getenv setenv LANGUAGE ..
.
http://billposer.org/Software/NumbersAndLocales.html
. LC_ALL ..
, ( ):
LANGUAGE
LC_ALL
LC_MESSAGES
LC_NUMERIC
LC_TIME
LC_COLLATE
: ll_CC, , - . , . , , .
ll_CC
At least gettext , the most popular translation structure in a Unix-like OS, is guided by these rules.https://gnu.org/software/gettext/manual/html_node/gettext_2.html#Locale-Environment-Variables