is there a way to find list of valid locales in my

2019-04-18 13:59发布

问题:

I need to find a list of locale installed/supported in my linux machine. is there a way to find a list of valid locales in my linux using perl ?

thanks

回答1:

This command will give you a list of locales:

locale -a

From a Perl script you can execute the same using

system("locale -a");


回答2:

If you want the list of all supported locales, in my Debian distro they are in /usr/share/i18n/SUPPORTED , so you could do:

system("cat /usr/share/i18n/SUPPORTED");


回答3:

my @locale_list = `locale -a`;
chomp(@locale_list);


回答4:

http://perldoc.perl.org/perllocale.html#Finding-locales:

For locales available in your system, consult also setlocale(3) to see whether it leads to the list of available locales (search for the SEE ALSO section). If that fails, try the following command lines:

locale -a
nlsinfo
ls /usr/lib/nls/loc
ls /usr/lib/locale
ls /usr/lib/nls
ls /usr/share/locale