获得语言目前在用户通过登录的AppleScript [英] get language of currently logged in user via applescript

查看:153
本文介绍了获得语言目前在用户通过登录的AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在当前登录用户的系统语言。行

I want to get the system language of the currently logged in user. The line

set lang to do shell script "defaults read NSGlobalDomain AppleLanguages"

返回一个字符串,它看起来像

returns an string, which looks like

(
    en,
    de,
    ja,
    fr,
    es,
    it,
    pt,
    "pt-PT",
    nl,
    sv,
    nb,
    da,
    fi,
    ru,
    pl,
    "zh-Hans",
    "zh-Hant",
    ko,
    ar,
    cs,
    hu,
    tr
)

返回用户的语言,但我怎么能得到这个'阵'的第一个?有没有解析这个作为数组的得到它的第一个值的可能?

returns the users languages, but how can I get the first one of this 'array'? Is there a possibility to parse this as an array an get its first value?

推荐答案

有一个更直接的方法。 AppleScript的有一个命令系统信息,它会返回大量的关于当前用户有用的信息。试一试,看看...

There's a more direct method. Applescript has a command "system info" which returns a lot of useful information about the current user. Try this to see...

return system info

这将帮助你从的信息是用户区域。所以,你可以轻松地获得语言...

The information that will help you from that is "user locale". So you can get the language easily...

return user locale of (get system info)

玩弄这对不同的用户,看看它给你想要的东西。

Play around with this on different users and see if it gives you what you want.

这篇关于获得语言目前在用户通过登录的AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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