如何从外壳中检测Mac OS X中的当前语言环境 [英] How to detect current locale in Mac OS X from the shell

查看:93
本文介绍了如何从外壳中检测Mac OS X中的当前语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从命令行检测OS X中的当前语言环境.在Linux/Unix上,我可以依赖LANG,但并非总是这样:

I need to detect the current locale in OS X from the command line. On Linux/Unix I can rely on LANG, but it is not always set:

http://henrik.nyh. se/2007/10/displaying-utf-8-正确在豹子终端

我正在寻找允许我查找该信息的命令行实用程序或AppleScript代码.理想情况下,它们将从10.2开始运行

I am looking for command line utilities or AppleScript code that allows me to find that information. Ideally they would work from 10.2 onwards

到目前为止我发现的最接近的是

The closest I have found so far is

defaults read -g AppleLocale

可从10.3开始使用

推荐答案

apropos生成命令locale

apropos yeilds the command locale

10.4及更高版本

defaults read .GlobalPreferences AppleLanguages | tr -d [:space:] | cut -c2-3

此处中提到了

.但是我无法访问10.2系统,所以我不知道它是否有效.

is mentioned here. I don't have access to a 10.2 system though, so I don't know if it works.

这篇关于如何从外壳中检测Mac OS X中的当前语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆