Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleLanguages in 10.2

AppleLanguages in 10.2
Thread Tools
wataru
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jan 14, 2005, 12:07 AM
 
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.
     
arekkusu
Mac Enthusiast
Join Date: Jul 2002
Status: Offline
Reply With Quote
Jan 14, 2005, 01:09 AM
 
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.
     
arekkusu
Mac Enthusiast
Join Date: Jul 2002
Status: Offline
Reply With Quote
Jan 14, 2005, 01:10 AM
 
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.
     
wataru  (op)
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jan 14, 2005, 01:24 AM
 
Ok, thanks. What a pain in the ass!
     
Rickster
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Jan 15, 2005, 07:34 PM
 
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.
Rick Roe
icons.cx | weblog
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 15, 2005, 09:50 PM
 
And in 10.3+ use CFLocale.
     
wataru  (op)
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jan 15, 2005, 11:54 PM
 
Ok, thanks a lot, guys.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:03 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,