 |
 |
Discovering system language
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I was wondering if there's an easy way to discover what the system's default language is, such as an environment variable or something. $LANG is an empty string by default on my machine, so I was hoping someone could point me in the right direction.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
In Cocoa:
Code:
[[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0];
It returns "English" for english, and the language code (e.g., "ja" or "de") for the other languages (which is strange, but there it is).
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Also, FWIW, $LANG is "en_US" on my machine.
Edit: Nevermind; I just noticed that $LANG doesn't change when the language order is changed in System Preferences.
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I should have specified, this is for a Bash script. And echo $LANG on my system gives me a blank line, even though my system language is Japanese. That's weird.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Oh, hah...sorry. I've gotten used to shell scripting questions appearing in the UNIX forum. You could try calling
Code:
defaults read 'Apple Global Domain' AppleLanguages
and parsing the result. Of course, if this is mean to run on a non OS X system, that won't work so well.
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |