Re: Getting the System languages
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.