Re: Determining preferred localizations
Re: Determining preferred localizations
- Subject: Re: Determining preferred localizations
- From: Rainer Brockerhoff <email@hidden>
- Date: Thu, 22 Apr 2010 08:50:10 -0300
At 12:02 -0700 21/04/10, email@hidden wrote:
>From: Gregory Weston <email@hidden>
>Date: Wed, 21 Apr 2010 09:59:48 -0400
>Message-ID: <email@hidden>
>
>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.
>...
>
>- (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];
>}
I can't double-check this right now, but I solved a similar problem this way:
NSArray* inChoices = [[NSBundle mainBundle] localizations]; // probably that's what you're passing in?
NSArray* theBestOnes = [NSBundle preferredLocalizationsFromArray:inChoices forPreferences:[NSLocale preferredLanguages]];
HTH,
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden