• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: extract system language
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extract system language


  • Subject: Re: extract system language
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 22 Jul 2004 12:49:56 -0700

On Jul 22, 2004, at 8:35 AM, Emmanuel Verlynde wrote:

How extract the systeme language code put in first position into system
prefs/international/language list?

Like en_us, en_ca, fr_be, ...

I'm not sure exactly what you're looking for. If you want to know what localization a particular application is running in, or would run in, that has to do with the user's localization preferences.

To find out what localization the current application is running in, use CFBundleCopyBundleLocalizations() and CFBundleCopyPreferredLocalizationsFromArray(), just like it says in the header; or if you are using NSBundle, [[NSBundle mainBundle] preferredLocalizations].

However, usually it isn't necessary to do this--usually you want to find out the localization not for its own sake, but so that you can key something off of it. In that case, just take the result you're interested in and make it a localizable resource, either a localizable string or a localizable file. You ought to be able to get a string representation of most shorter items, and a file representation of most longer items.

If you want to find out what localization some other application would run in, use CFBundleCopyBundleLocalizations() and CFBundleCopyLocalizationsForPreferences(..., NULL) or -[NSBundle preferredLocalizationsFromArray:forPreferences:].

If you want to find out what localizations the user prefers independent of whether any application might ever run in them, you can consult the AppleLanguages user default. However, I would recommend against doing this if you can at all avoid it, because there are a wide variety of formats that can appear in it, and you would have to handle them all. Better to let CFBundle/NSBundle do it, and be safe (and future-proof). You can use CFBundleCopyLocalizationsForPreferences() or -[NSBundle preferredLocalizationsFromArray:forPreferences:] to select which of any list of localizations the user would prefer--this handles most needs safely.

Douglas Davidson
_______________________________________________
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.


References: 
 >extract system language (From: "Emmanuel Verlynde" <email@hidden>)

  • Prev by Date: Re: keyedobjects.nib
  • Next by Date: Re: NSData being retained?
  • Previous by thread: Re: extract system language
  • Next by thread: NSTask Suspend/Resume
  • Index(es):
    • Date
    • Thread