This is pretty much This question with a bit more information. My goal is to work out the languages installed in the system.
The following command
locale -a
displays all the languages (in a format such as en_AU.utf8). This seems to correspond to the contents of /usr/lib/locale.
Furthermore, invoking
LANG=fr_FR.utf8 locale -ck LC_IDENTIFICATION
Gives information of that particular locale which includes the language name (Which in this case is French).
This seems to be the information contained in /usr/lib/locale/fr_FR.utf8/LC_IDENTIFICATION.
Is there a way (maybe an API call) to obtain this info? I looked at the source of the locale utility but it uses a private struct.
How to View System Locale in Linux. To view information about the current installed locale, use the locale or localectl utility. You can view more information about an environmental variable, for example LC_TIME, which stores the time and date format.
To display the current character set for the locale, use locale -c charmap.
The locale setting defines the language of your user interface and the display formats for information like time, date, and currency.
Answer. The LC_ALL variable sets all locale variables output by the command 'locale -a'. It is a convenient way of specifying a language environment with one variable, without having to specify each LC_* variable. Processes launched in that environment will run in the specified locale.
I think, you could just get environment variables, using, for example, getenv(3)
, thus you would want to pass it the name of variable, e. g.:
char *s;
s = getenv("LANG");
if (s == NULL)
printf("LANG is not set");
else
printf(s);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With