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