I see what you're getting. The issue is that the keys you're getting back by utilizing kDisplayProductName from IOKit only have paired language/territory (e.g., "en_US") while the AppleLanguages array in your setups have non-paired ones for most languages (e.g., "en"). If you were to turn on paired language/territories in the System Preferences (e.g., "U.S. English") in the desired order, you could get what you're wanting. Basically, you're asking for something highly specific, but the configurations only provide more general, so fallbacks go a lot farther than what you want.
The only way I've been able to bypass this without adding settings to the System Preferences is to split the pairs and introduce language-only objects after each pair provided such strings are not already present. So, you would rework your array on the MacBook Core 2 Duo 10.6.3 from: "nl_NL" "da_DK" "pl_PL" "en_US" "nb_NO" "fr_FR" "pt_BR" "pt_PT" "zh_CN" "es_ES" "ja_JP" "ru_RU" "sv_SE" "zh_TW" "de_DE" "fi_FI" "it_IT" "ko_KR" to: "nl_NL" "nl" "da_DK" "da" "pl_PL" "pl" "en_US" "en" "nb_NO" "nb" "fr_FR" "fr" "pt_BR" "pt_PT" "pt" "zh_CN" "es_ES" "es" "ja_JP" "ja" "ru_RU" "ru" "sv_SE" "sv" "zh_TW" "de_DE" "de" "fi_FI" "fi" "it_IT" "it" "ko_KR" "ko" Not sure how Chinese would work, though, since there's really not a practical locale of "zh". Also, you may have issues with the "Hans" vs. "CN" convention. Look at the locale APIs to help with splitting and normalizing these values. On 04/21/2010 1:54 PM, "Gregory Weston" <gwes...@mac.com> wrote: > Gary L. Wade wrote: > >> The list you are getting is a set of preferred localizations, so when trying >> to get a resource from the first one, if not available, will go on to the >> next one and so forth. >> >> You should utilize the localization-aware methods to handle getting >> resources rather than trying to manage this yourself. There's really only >> two reasons I've encountered a need for this kind of granularity, the first >> where you're forced to use a set of legacy resources that you're unable to >> move into the right places, and the second a localization utility. > > I think one of us has misunderstood, because I'm not sure how this response > actually addresses my question. I'll restate and try to be more clear. > > I'm trying to present to the user a list of the attached displays. For any > given display device, the "name" I get from IOKit is not a string but a > dictionary mapping locale identifiers to localized versions of the device > name. My goal is to determine which of the dictionary entries to use. > > I thought NSBundle's preferredLocalizationsFromArray: and > CFBundleCopyPreferredLocalizationsFromArray() would take an array made up of > those dictionary keys and give me back a subset of the list, prioritized based > on such things as the user's localization settings and the available > localizations within the app. What I'm getting is an array containing a single > entry which doesn't match the app's development region, doesn't match any set > of localization resources in the app and is at an unpredictable (although > consistent per machine) offset in the user's preferred language list. > > System Profiler and the Displays pref pane both show the appropriate value. > I'm sure I'm doing something wrong but I don't know what. > > Short form: How do I get from an NSScreen or a CGDirectDisplayID to the most > appropriate human-readable name for the display? > > Greg _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com