Type Method

preferredLocalizationsFromArray:forPreferences:

Returns locale identifiers for which a bundle would provide localized content, given a specified list of candidates for a user's language preferences.

Declaration

+ (NSArray<NSString *> *)preferredLocalizationsFromArray:(NSArray<NSString *> *)localizationsArray forPreferences:(NSArray<NSString *> *)preferencesArray;

Parameters

localizationsArray

An array of identifiers, each corresponding to a localization that a bundle can support.

preferencesArray

An array of BCP 47 language codes corresponding to a user's preferred languages.

If this parameter is nil, the method uses the current user's language preferences.

Return Value

An array of locale identifiers, ordered according to user preference.

If none of the user-preferred localizations are available, this method returns one of the values in localizationsArray.

Discussion

This method returns only the locale identifiers for which a bundle would provide localized content. Typically, this means one of the following:

  • A single localization that isn't region-specific

  • A region-specific localization, followed by a corresponding localization that isn't region-specific, as a fallback

This method doesn't return all localizations in order of user preference. To get this information, you can call this method repeatedly, each time removing the identifiers returned by the previous call.

See Also

Getting Localization Information

localizations

A list of all the localizations contained in the bundle.

preferredLocalizations

An ordered list of preferred localizations contained in the bundle.

developmentLocalization

The localization for the development language.

localizedInfoDictionary

A dictionary with the keys from the bundle’s localized property list.

+ preferredLocalizationsFromArray:

Returns one or more localizations from the specified list that a bundle object would use to locate resources for the current user.