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.
Thanks to Yasir. This is exactly what I wanted:
#include <langinfo.h>
char *s;
s = getenv("LANG");
if (s == NULL)
printf("LANG is not set");
else {
setlocale(LC_ALL, s);
printf(nl_langinfo(_NL_IDENTIFICATION_LANGUAGE));
}