Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between preferredLocalization and preferredLanguage?

Definition of [NSLocale preferredLanguages] according to the documentations:

The user's language preference order as an array of NSString objects, each of which is a canonicalized IETF BCP 47 language identifier.

Definition of [[NSBundle mainBundle] preferredLocalizations]:

An array of NSString objects, each of which identifies the a localization in the receiver’s bundle. The languages are in the preferred order.

I really don't get what the difference is. Which one should be one using?

like image 574
Enrico Susatyo Avatar asked Mar 01 '12 00:03

Enrico Susatyo


1 Answers

I believe language is just language, but locale implies a great deal more (e.g. calendar/date computations, currency, number formatting, etc). The Locales Programming Guide is a short read, a great place to start.

More specifically, +preferredLocalizations, being a bundle resource, is a component of an app itself, configurable during app design, whereas +preferredLanguages, coming from NSLocale (btw it's a class method, not an object method) represents the system-level preferences of the user.

Therefore, +preferredLocalizations provides the language the app is actually running in whereas +preferredLanguages provides the language the user prefers their apps to run in (even if the apps don't yet support it).

like image 134
QED Avatar answered Oct 30 '22 03:10

QED