fix: Fixed panic when use ru lang for translation, added and fixed tests #814
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Panic when using Russian for translations of some tags with values other than 1
When we use:
We get panic when validating structures with tags min, len, etc. You didn't get an error in your tests, because used:
instead of
Panic arises because in the locales package for the Russian language the CardinalPluralRule function differs in its implementation of the function in English.
RU:
EN:
This led to panic in the program when we used some tags with numbers other than 1.
It should also be borne in mind that the suffix at the end of words in Russian changes not only depending on the number in front, but also on the structure of the sentence, therefore they are not the same for different tags and additional tests have been written for this. And if the structure of the message output changes in the future, then the suffixes at the end of words may also change, but at the moment they are correct.
It is also worth noting that in this context locales.PluralRuleOther will never drop out in Russian, but I left the implementation in the ru module, because the function can return the given value.