gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with NSLocale- preferredLanguages method


From: Stef Bidi
Subject: Re: Need help with NSLocale- preferredLanguages method
Date: Tue, 27 Jul 2010 19:46:45 -0500

Asha
 
I'm CCing dev list just in case anyone else have other ideas...
 
GNUstep allows the preffered language to be set using the defaults system.  In order to get the user's preferred languages you'd have to query that.  Currently, -preferredLanguages just queries [NSUserDefaults +userLanguages], which is a GNUstep addition as far as I can tell.  In my opinion, this is the right thing to do, but the strings are NOT in the correct format and a lookup table in needed.
 
GNUstep-base already has a .plist with languages and locales in Resources/Languages/Locale.aliases, but it goes in the wrong direction.  NSLocale would need exactly that same list, but backwards... you'd be searching for AmericanEnglish, for example, and would expect en_US back.  Take a look in Source/GSLocale.m (GSLanguageFromLocale function) to see how base currently uses Locale.aliases.  The same exact thing would have to be done with the other plist.  Pretty much you'd want something like GSLocaleFromLanguage().
 
Clear as mud?  One of the more experienced (and by that I mean way more experienced than me) devs might be able to come up with something better.
 
Stef
On Tue, Jul 27, 2010 at 5:00 PM, asha murthy <address@hidden> wrote:
Hi Stef,

I am trying to implement the preferredLanguages  method for NSLocale class.
I have an idea of how this should be done but am not sure how in objective C.

1)Create a property list for languages
2)Create the .plist file
3) Use NSUserDefaults in the method to return the sorted array with most preferred language that user choses at run time.

Could you please give me some input on how this can be done in Objective C?

Thanks,
Asha



reply via email to

[Prev in Thread] Current Thread [Next in Thread]