• 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: MacInsight <email@hidden>
  • Date: Sun, 17 Aug 2003 18:55:37 +0200

Hi,

Am Sonntag, 17.08.03 um 15:35 Uhr schrieb Jesus De Meyer:

I tried this in my code but it returns (null). I need to get the chose
language from the system, so if anyone can help, I'd appreciate it alot.

NSDictionary *globalDefaults = [[NSUserDefaults standardUserDefaults]
persistentDomainForName:@"NSGlobalDomain"];

NSLog(@"Languages are: %@", [[globalDefaults
objectForKey:@"AppleLanguages"] description]);

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".

hth,
Dirk Stegemann
_______________________________________________
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.

  • Follow-Ups:
    • Re: Getting the System languages
      • From: Douglas Davidson <email@hidden>
References: 
 >Getting the System languages (From: Jesus De Meyer <email@hidden>)

  • Prev by Date: Folder Icon
  • Next by Date: Re: Panter WebKit.framework on 10.2
  • Previous by thread: Getting the System languages
  • Next by thread: Re: Getting the System languages
  • Index(es):
    • Date
    • Thread