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

symbol can't be argument for :count in east slavic locales #2900

Conversation

bitberry-dev
Copy link

@bitberry-dev bitberry-dev commented Oct 7, 2018

Hi guys!

Symbol can't be argument for :count in east slavic locales, east slavic pluralization rule requires number because it uses modulo division, https://github.com/svenfuchs/rails-i18n/blob/master/lib/rails_i18n/common_pluralizations/east_slavic.rb

ericsaupe
ericsaupe previously approved these changes Oct 11, 2018
Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@ericsaupe ericsaupe dismissed their stale review October 11, 2018 16:33

Would you mind changing the commit message to something shorter? You can include more description on additional lines below

@jacobherrington
Copy link
Contributor

@bitberries thanks for making this PR! 🎉

We have some great resources for writing good commit messages in our contributing.md file, if you're interested!

@bitberry-dev bitberry-dev force-pushed the bugfix/promotion_category_index_exception branch from ebeb8c0 to 0f2cc9e Compare October 11, 2018 16:51
@bitberry-dev
Copy link
Author

Changed commit message, is it okay now?

Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thanks!

@kennyadsl
Copy link
Member

@bitberries I'm not sure to get the issue with current code and the link provided does not help understanding (for me). Can you please point to some other resource or explain the issue better?

@bitberry-dev
Copy link
Author

Just try to visit this page with russian locale and you will get exception.

@bitberry-dev
Copy link
Author

bitberry-dev commented Oct 18, 2018

2018-10-19 0 43 33
Exception screenshot, just visit /admin/promotion_categories?locale=ru
P.S. Spree also has this bug last 2 years

@bitberry-dev
Copy link
Author

Also I never saw that count parameter was not numerical. Everywhere it is number. It is assumed by pluralization rules that it will be a number, check it https://github.com/svenfuchs/rails-i18n/tree/master/lib/rails_i18n/common_pluralizations - everywhere comparisons only with numbers.

This code is just randomly working correctly for the English language.

@kennyadsl
Copy link
Member

kennyadsl commented Oct 18, 2018

This code is just randomly working correctly for the English language.

That's what I was trying to understand, thanks. It looks like it's not supported by rails-i18n so we should avoid using it here as for your PR.

I've also found the initial work for this in Solidus: #1191

Are there other occurrences of this wrong pluralization in Solidus? It is worth to update all of them in this PR maybe, what do you think?

@bitberry-dev
Copy link
Author

I have not found more similar errors (via grep), but if I notice something like this I will definitely make a pool request! Solidus is great project with clean code (in comparison with spree) and I will help make it better :)

@kennyadsl
Copy link
Member

@bitberries I've just found this one:

expect(page).to have_link Spree::LegacyUser.model_name.human(count: :other), href: spree.admin_users_path

This should be unsupported as well. I know that this will not break any thing since specs does not run with east slavic locale but we should not encourage bad practices in the codebase. Every line of code could be taken as example and reused again, maybe somewhere where it will be dangerous.

@bitberry-dev
Copy link
Author

Yep, you are right. I fixed it.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a question, also I think you can squash commits and change the commit message to reflect both changes, thanks!

backend/spec/features/admin/users_spec.rb Show resolved Hide resolved
@bitberry-dev bitberry-dev force-pushed the bugfix/promotion_category_index_exception branch from 02fc8d3 to 95ae416 Compare October 19, 2018 15:48
@bitberry-dev
Copy link
Author

Now using plural_resource_name in spec.
Squashed into one commit.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I suggested to add this but thinking twice it's better to don't add implementation details to the feature specs expectations.

backend/spec/features/admin/users_spec.rb Outdated Show resolved Hide resolved
@bitberry-dev bitberry-dev force-pushed the bugfix/promotion_category_index_exception branch from 95ae416 to fc8c072 Compare October 25, 2018 12:26
Symbol can't be argument for :count in east slavic locales, east slavic pluralization rule requires number because it uses modulo division, https://github.com/svenfuchs/rails-i18n/blob/master/lib/rails_i18n/common_pluralizations/east_slavic.rb
@bitberry-dev bitberry-dev reopened this Oct 25, 2018
@kennyadsl kennyadsl merged commit 76e1f8b into solidusio:master Nov 9, 2018
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

Successfully merging this pull request may close these issues.

4 participants