• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the System languages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the System languages


  • Subject: Re: Getting the System languages
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 18 Aug 2003 11:35:41 -0700

For most purposes I do not recommend dealing with the value of the AppleLanguages default directly, for the reasons indicated below--it can contain entries in a variety of formats, and a greater variety may be possible in the future. Where possible, I recommend using CFBundle API. CFBundle is the authoritative source for handling of this default, and it has API that can be combined to extract most of the information that one would want from this default. See the header for more information on CFBundleCopyLocalizationsForPreferences() and related functions.

Douglas Davidson

On Sunday, August 17, 2003, at 09:55 AM, MacInsight wrote:

I was looking for the language values too, this solution has been posted to the list some time ago (by an Apple engineer, IIRC):

// try to get the users settings in the System Preferences "International" PreferencePane
CFArrayRef array = (CFArrayRef)CFPreferencesCopyValue(CFSTR("AppleLanguages"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (array != nil) {
CFIndex arrayCount = CFArrayGetCount(array);
if (arrayCount > 0) {
CFStringRef languageString = (CFStringRef)CFArrayGetValueAtIndex(array, 0);
if (languageString != nil) {
if(isGermanSystemLanguage((int)languageString)) {
return MultiLanguageSupport::GERMAN;
} else {
return MultiLanguageSupport::ENGLISH;
}
}
CFRelease(languageString);
}
CFRelease(array);
}

Though not Cocoa but CoreFoundation, it has always been worked for me.
Be aware of the pitfalls: the returned strings can be in different formats, i.e. "English" or "en" or even "us_en".
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Getting the System languages (From: MacInsight <email@hidden>)

  • Prev by Date: Re: [OT] Installation into home directory
  • Next by Date: Re: Front-to-back ordering in IB changes
  • Previous by thread: Re: Getting the System languages
  • Next by thread: Folder Icon
  • Index(es):
    • Date
    • Thread