有没有办法使用 perl 在我的 linux 中查找有效语言环境列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12521713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:24:46  来源:igfitidea点击:

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

linuxperllocale

提问by user1318538

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 ?

我需要在我的 linux 机器中找到安装/支持的语言环境列表。有没有办法使用 perl 在我的 linux 中找到有效语言环境的列表?

thanks

谢谢

回答by Jean

This command will give you a list of locales:

此命令将为您提供区域设置列表:

locale -a

From a Perl script you can execute the same using

从 Perl 脚本中,您可以使用

system("locale -a");

回答by Nelson

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

如果您想要所有受支持语言环境的列表,在我的 Debian 发行版中,它们位于 中/usr/share/i18n/SUPPORTED,因此您可以执行以下操作:

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

回答by PSIAlt

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

回答by ysth

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

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:

对于您系统中可用的语言环境,还可以参考 setlocale(3) 以查看它是否指向可用语言环境的列表(搜索 SEE ALSO 部分)。如果失败,请尝试以下命令行:

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

回答by Yevgeniy Afanasyev

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

如果通过说“有效的语言环境”你想检查哪些语言环境是 supported

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

然后您需要转到该文件(您可以使用“nano”打开它以检查它是否仍然存在)

nano /usr/share/i18n/SUPPORTED

tested on Ubuntu 18

在 Ubuntu 18 上测试