Since pluralization use String class function localizedStringWithFormat which
Returns a string created by using a given format string as a template into which the remaining argument values are substituted according to the user’s default locale.
..so it takes user’s default locale. For example if you have the device with English, but in app choose Russian, it will take the plural type for English, but plural string for Russian. We know, that for English used only one and other types. For Russian used all (one, two, few, many..). But the app, in that case, will return only one and other for Russian.
It goest to a correct .stringsdict file, but ignores plural categories, which are not used in device's current language.
The problem is because when changing language in app, we substitute bundle and then use this bundle to take localized string. But in order to use pluralization we need to use only one available function for this: localizedStringWithFormat. And it uses the device localization.
It seems that it's a bug because String.localizedStringWithFormat always use categories for current device language even if UserDefaults.standard added a recent key for AppleLanguages.
Workaround:
Is to use custom implementation of pluralization.
Since pluralization use String class function
localizedStringWithFormat
which..so it takes user’s default locale. For example if you have the device with English, but in app choose Russian, it will take the plural type for English, but plural string for Russian. We know, that for English used only
one
andother
types. For Russian used all (one, two, few, many..). But the app, in that case, will return onlyone
andother
for Russian.It goest to a correct
.stringsdict
file, but ignores plural categories, which are not used in device's current language.The problem is because when changing language in app, we substitute bundle and then use this bundle to take localized string. But in order to use pluralization we need to use only one available function for this:
localizedStringWithFormat
. And it uses the device localization.It seems that it's a bug because
String.localizedStringWithFormat
always use categories for current device language even ifUserDefaults.standard
added a recent key forAppleLanguages
.Workaround: Is to use custom implementation of pluralization.