Re: Language tags
Re: Language tags
- Subject: Re: Language tags
- From: MacInsight <email@hidden>
- Date: Fri, 18 Apr 2003 16:57:14 +0200
Hi,
Am Montag, 14.04.03 um 07:33 Uhr schrieb mmalcolm crawford:
On Sunday, April 13, 2003, at 08:48 PM, mmalcolm crawford wrote:
On Friday, April 4, 2003, at 12:46 AM, Yuhui wrote:
I've figured out how to use NSUserDefaults to get the user's
language. But the iCalendar format uses the 2-letter ISO 639 format,
e.g. "English" = "en". Short of writing a lookup table, is there any
Apple built-in function/dictionary to convert a language into the
2-letter version?
The only way I've found so far is to use IntlUtility, as in:
For further background, I have looked through all the functions etc. in
<file:///Developer/Documentation/Carbon/text/LocaleUtilities/
Locale_Utilities/Miscellaneous/ManagerIntro.html>
but haven't found anything to reliably get from, say, "English" to
"en".
I'd be interested in an answer to a related question:
how is it possible to get different results from the same code on
different machines which have the same language settings?
I'm using a code snippet which has been posted earlier to this list and
works fine (see below), giving me a reliable information about the
user's current language settings; but on one machine (G4-500x2,
10.2.5), I get "de" or "en" for a german resp. english setting, whereas
the other machine (G4-867x2, 10.2.5) returns for the same settings
"German" resp. "English".
To determine if it's english or german, I do a
CFStringCompare()
but i'd like to know if I have to consider to get even more different
result-strings than these two ones ("German", "de"), perhaps "deutsch"
or "allemagne"?
Any insight appreciated,
Dirk Stegemann
--
code snippet:
// 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) {
// do the CFStringCompare() stuff here. sometimes we're seeing "de"
or "en", other times it's "German" or "English"
}
}
}
_______________________________________________
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.