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.


On 04/21/2010 6:59 AM, "Gregory Weston" <gwes...@mac.com> wrote:

> I'm trying to display a localized list of attached displays, and getting
> unexpected results in Carbon and Cocoa when attempting to determine the best
> localization. I did all the obvious-to-me Google searches without finding much
> except a couple of other people over the years having similar issues and no
> real resolution. Sample code and results follow. Hoping someone can point me
> in the right direction.
> 
> FWIW, I've tried both "en" and "English" for both the Info.plist development
> region and the localized resources folder in the app.
> 
> Thanks for any help.
> 
> Greg
> 
> - (NSString*)bestLocalization:(NSArray*)inChoices
> {
>   NSUserDefaults* theDefaults = [NSUserDefaults standardUserDefaults];
>   NSArray* theUserSettings = [theDefaults objectForKey:@"AppleLanguages"];
>   NSLog(@"User Settings: %@", theUserSettings);
> 
>   NSLog(@"Choices: %@", inChoices);
> 
>   NSArray* theBestOnes = [NSBundle preferredLocalizationsFromArray:inChoices];
>   NSLog(@"Chose: %@", theBestOnes);
> 
>   return [theBestOnes objectAtIndex:0];
> }
> 
> Mac mini (Early 2009) 10.6.3 with Dell 2007WFP:
> 
> User Settings: (English)
> Choices: ("en_US")
> Chose: ("en_US")
> 
> MacBook Core 2 Duo 10.6.3:
> 
> User Settings: (en, fr, ja, de, es, it, nl, sv, nb, da, fi, pt, "zh-Hans",
> "zh-Hant", ko, ru, pl, "pt-PT")
> Choices: ("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")
> Chose: ("zh_CN")
> 
> MacBook Pro 10.5.8 plus Apple Cinema Display:
> 
> User Settings: (en, fr, ja, de, es, it, pt, "pt-PT", nl, sv, nb, da, fi, ru,
> pl, "zh-Hans", "zh-Hant", ko)
> Choices: ("it_IT", "en_US", "ko_KR", "fi_FI", "nb_NO", "ru_RU", "zh_CN",
> "nl_NL", "de_DE", "ja_JP", "pl_PL", "es_ES", "fr_FR", "zh_TW", "da_DK",
> "sv_SE", "pt_BR", "pt_PT")
> Chose: ("fr_FR")
> User Settings: (en, fr, ja, de, es, it, pt, "pt-PT", nl, sv, nb, da, fi, ru,
> pl, "zh-Hans", "zh-Hant", ko)
> Choices: ("it_IT", "en_US", "ko_KR", "fi_FI", "nb_NO", "ru_RU", "zh_CN",
> "nl_NL", "de_DE", "ja_JP", "pl_PL", "es_ES", "fr_FR", "zh_TW", "da_DK",
> "sv_SE", "pt_BR", "pt_PT")
> Chose: ("fr_FR")
> _______________________________________________
> 
> 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/garywade%40desisoftsystems.co>
m
> 
> This email sent to garyw...@desisoftsystems.com


_______________________________________________

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

Reply via email to