The 3 preferredLocalizations
of Bundle
are so confusing that I have so many questions:
Why the 2
preferredLocalizations
methods are class methods but keep talking about some unspecified specific bundle as if they are called on some individualBundle
instance?preferredLocalizations(from:)
: What exactly area bundle object
andthe bundle
?Returns one or more localizations from the specified list that a bundle object would use to locate resources for the current user.
An array of NSString objects, each of which specifies the language ID for a localization that the bundle supports.
preferredLocalizations(from:forPreferences:)
: What exactly arethe specified bundle
andthe receiver’s bundle
?Returns the localizations that a bundle object would prefer, given the specified bundle and user’s language preferences.
An array of NSString objects, each of which identifies a localization in the receiver’s bundle. These strings are ordered in the array according to the specified preferences and are taken from the strings in the localizationsArray parameter. If none of the user-preferred localizations are available in the bundle, this method returns one of the bundle localizations.
Why
preferredLocalizations(from: localizations)
does't return the same result aspreferredLocalizations(from: localizations, forPreferences: nil)
? As noted above reading their docs doesn't really help. Sure they look designed this way but actually not:// Locale.preferredLanguages: ["es-CN", "ja-CN", "zh-Hans-CN", "en-CN", "he-IL"]. let localizations = ["de", "en", "es", "fr", "it"] print(Bundle.preferredLocalizations(from: localizations)) // ["en"] print(Bundle.preferredLocalizations(from: localizations, forPreferences: nil)) // ["es"]