user1318538
user1318538

Reputation: 341

is there a way to find list of valid locales in my linux using perl?

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

Upvotes: 32

Views: 42128

Answers (5)

Yevgeniy Afanasyev
Yevgeniy Afanasyev

Reputation: 41360

if by saying "valid locales" you wanted to check which locales are supported

then you need to go to the file (you can open it with 'nano' to check if it is still there)

nano /usr/share/i18n/SUPPORTED

tested on Ubuntu 18

Upvotes: 0

ysth
ysth

Reputation: 98398

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

Upvotes: 2

Galimov Albert
Galimov Albert

Reputation: 7357

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

Upvotes: 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");

Upvotes: 10

Jean
Jean

Reputation: 22695

This command will give you a list of locales:

locale -a

From a Perl script you can execute the same using

system("locale -a");

Upvotes: 48

Related Questions