Learn the default language on Linux

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!

0
source share
3 answers

Typically, an environment variable LANGcontains this information in the format "de_DE.UTF-8".

You can get it using the function getenv.

EDIT:

For more complex internationalization, you may need to learn gettext .

+1

getenv setenv LANGUAGE ..

.

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

. LC_ALL ..

0

, ( ):

  • LANGUAGE
  • LC_ALL
  • LC_MESSAGES, LC_NUMERIC, LC_TIME, LC_COLLATE
  • LANG

: 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

0
source

All Articles