0

Macでユーザーの言語設定(言語名で十分)を知るための端末コマンドは何ですか?シェルスクリプトを提供できますか?

4

1 に答える 1

1

You can get a list of the user's language preferences with defaults read NSGlobalDomain AppleLanguages. OS X will use the languages in decreasing order of preference (if the first one is not available in a particular app). On my machine:

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

In bash, to get the first one (the primary UI language), you can slice off the first one with this (admittedly messy) script:

 langs=(`defaults read NSGlobalDomain AppleLanguages`)
 echo ${langs[1]/,/} # langs[0] is the open bracket
于 2013-02-16T08:00:08.903 に答える