|
|
AppleLanguages in 10.2
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I posted this in the UNIX forum, but got no responses after several days:
In one of my apps, I detect the system language by reading the output of the command
Code:
defaults read 'Apple Global Domain' AppleLanguages
On my system, that returns a string like
Code:
(ja, en, "zh_CN", "zh_TW", de, fr, es, it)
However, in a bug report submitted by a user, the output looked something like
Code:
English
German
French
Dutch
Italian
Japanese
Spanish
da
fi
ko
no
pt
sv
"zh_CN"
"zh_TW"
Is this what the output looks like for OS X 10.2? (I'm running 10.3)
I found this thread that would seem to indicate that the problem is a corrupt AppleLanguages key, but I just wanted to confirm that this is the case.
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jul 2002
Status:
Offline
|
|
That's correct output, it is not corrupt. Since OS X 10.0, some of the languages were referred to by English names. That behavior is deprecated now. See the bottom of the Language Designationsdocs.
However, even though it is deprecated, you can see very easily that Apple apps still use the old names:
%ls /Applications/*/Contents/Resources/ | grep .lproj
So you'll have to deal with the English language names. There's a fixed number of them, so make a lookup table.
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jul 2002
Status:
Offline
|
|
Originally posted by arekkusu:
That's correct output, it is not corrupt. Since OS X 10.0, some of the languages were referred to by English names. That behavior is deprecated now. See the bottom of the Language Designationsdocs.
However, even though it is deprecated, you can see very easily that Apple apps still use the old names:
%ls /Applications/*/Contents/Resources/ | grep .lproj
So you'll have to deal with the English language names. There's a fixed number of them, so make a lookup table.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Ok, thanks. What a pain in the ass!
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Languages were referred to by their English names in OPENSTEP, and the practice continued until 10.0 or 10.1... the reason you're seeing them in the user's defaults is most likely because the user has kept the same home folder (or at least the relevant preference files) since an old version of Mac OS X and not changed their language preferences since.
So yeah, you'll need a lookup table to standardize your input. Actually, you can steal the lookup tables from /System/Library/PrivateFrameworks/IntlPreferences.framework if you want -- they've got complete mappings for English name, ISO code, and localized name (e.g. English, Deutsch, Italiano, Norsk, etc.). I'd recommend copying what tables you need into your app instead of relying on the ones in /System; since they're under PrivateFrameworks they're subject to change without warning.
BTW, you can get easier access to the defaults database by using the NSUserDefaults class or the CFPreferences API.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
And in 10.3+ use CFLocale.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|