Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect current locale in Mac OS X from the shell

Tags:

macos

locale

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-correctly-in-leopard-terminal

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

which works on 10.3 onwards

like image 528
Daniel Lopez Avatar asked Mar 19 '09 11:03

Daniel Lopez


1 Answers

apropos yeilds the command locale

10.4 and later though

Edit:

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

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

like image 122
cobbal Avatar answered Sep 30 '22 19:09

cobbal