Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
I am using Obj C with Cocoa framework.
The language on my Mac is English.

I am trying to get the language preference of my Mac using the following code:
Code:
userLocaleRef = CFLocaleCopyCurrent();
CFShow(CFLocaleGetIdentifier(userLocaleRef));

It is displaying en_IN when I am running the application from console. Its fine.

Now I changed my language to simple chinese using System PReferences -> International and restarted my Mac.

Still above code is displaying en_IN only.
How to get the language code of my Mac to which it is currently set?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Not sure why it's not working, but since you're using Cocoa you can use NSLocale instead of the CF functions.

Also when you change the localization settings in System Preferences you only need to relaunch the app, not restart. Makes it a bit easier for testing :)
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Not sure why it's not working, but since you're using Cocoa you can use NSLocale instead of the CF functions.

Also when you change the localization settings in System Preferences you only need to relaunch the app, not restart. Makes it a bit easier for testing :)

I think the "language" setting only changes the order in which different language resources in an application are chosen; this cannot give you chinese language unless you have chinese resource. I would also check what happens when the format options are changed.
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Change the Info.plist part:

Code:
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>

That's what sets the app's default language.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.