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

Improve I18n pluralization to avoid errors with some calculators #1191

Merged
merged 3 commits into from
May 25, 2016

Conversation

fredericboivin
Copy link
Contributor

(Duplicate, closed the other one to avoid starting builds while I was working on it and I can't reopen it because I forced pushed the original branch, sorry about that)

This is a fix for issue #1164

  1. First commit is to add a constant containing the "magic number" we want to use
  2. Second commit is to add the helper to wrap the usage of ActiveRecord::Naming
  3. Third commit is find/replace to use the helper

It is likely that we'll need to add more keys to fully support every pluralization calculators (slavic languages use more keys like : [ few, many ] and we only use one/other) but this address the underlying issue of trying to compare if a Symbol is less or greater than an integer which was causing crashes with the OneUptoTwoOther calculator used by the french language.

Replaced the original preference by a simple constant (thanks jhawthorn), but I kept the helper usage

Suggestions welcome

Add a constant to be used as a value for the
count: parameter in the Model.model_name.human
pluralization context to the i18n file
Add an helper to wrap the I18n pluralization so
it's easier to update the logic or the number for
the count
Replace all calls to Model.model_name.human with
plural_resource_name(Model) instead
@tvdeyen
Copy link
Member

tvdeyen commented May 25, 2016

👍

1 similar comment
@mamhoff
Copy link
Contributor

mamhoff commented May 25, 2016

👍

@mamhoff mamhoff merged commit a4a2462 into solidusio:master May 25, 2016
@fredericboivin fredericboivin deleted the update_pluralization branch May 25, 2016 14:10
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.

3 participants