Search code examples
cocoalocalizationnsbundle

Why does NSBundle only return the first localization present in a bundle that matches the user's language preferences instead of all matches?


Given the localization directories returned by -[NSBundle localizations]

(en, es, it, nl)

and the language preferences set by the user as returned by -[NSLocale preferredLanguages]

( en, es, nl, ja, fr, de, it, pt-PT, sv, nb, fi, zh-Hans, zh-Hant, ko )

I expect all four available localizations to be returned in the preferred language order by -[NSBundle preferredLocalizationsFromArray:] (or -preferredLocalizations or -preferredLocalizationsFromArray:forPreferences:).

Instead, -preferredLocalizationsFromArray: returns only "en" as a viable source of localized resources.

Why?


Solution

  • The documentation for preferredLocalizationsFromArray: says

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

    I guess it's one and not or more.

    You should probably file a bug about it.