determining Preferred Language in OS X via cli I was hoping to do something like:

defaults read -g AppleLanguages | awk -F, '/[^(]/{print $1;exit}'


but if only one language is listed in "Preferred Languages", then defaults read -g AppleLanguages returns an error:


  The domain/default pair of (kCFPreferencesAnyApplication, AppleLanguages) does not exist


It works fine if multiple languages are listed.
Does anyone have a reliable way of determining the language selected for a given user in OS X?
The only difference is the comma.  Conditionally remove the comma if it's there.

defaults read -g AppleLanguages | sed -n "2p" | tr -d ,