CFLocaleCopyCurrent ????

Discussion in 'Mac Programming' started by satyam90, Sep 25, 2008.

  1. macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    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?
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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 :)
     
  3. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #3
    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.
     
  4. macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #4
    Change the Info.plist part:

    Code:
    	<key>CFBundleDevelopmentRegion</key>
    	<string>English</string>
    That's what sets the app's default language.
     
  5. thread starter macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #5
    I coldn't find code how to use NSLocale to get current language of Mac..........can some body tell me how to?
     

Share This Page