Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralization don't work (explanation) #138

Open
NikKovIos opened this issue Aug 13, 2019 · 1 comment
Open

Pluralization don't work (explanation) #138

NikKovIos opened this issue Aug 13, 2019 · 1 comment

Comments

@NikKovIos
Copy link

NikKovIos commented Aug 13, 2019

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.

@NikKovIos NikKovIos changed the title Plurization don't work (explanation) Pluralization don't work (explanation) Aug 13, 2019
@NikKovIos
Copy link
Author

It seems that here is a woking solution for pluralization https://github.com/andresilvagomez/Localize. Didn't test yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant