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

Bug: Pluralization and Fallbacks modules do not play well together #124

Open
yaroslav opened this issue Nov 21, 2011 · 8 comments
Open

Bug: Pluralization and Fallbacks modules do not play well together #124

yaroslav opened this issue Nov 21, 2011 · 8 comments
Milestone

Comments

@yaroslav
Copy link
Collaborator

Related (RU, may want to use Google Translate): yaroslav/russian#29 (comment)

Summary:

pluralize method of Backend::Pluralization relies on resolving pluralize rule this way:

        def pluralizer(locale)
          pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false)
        end

# ...

        pluralizer = pluralizer(locale)
        if pluralizer.respond_to?(:call)
          # ... do call that ...
        else
          super
        end

Unfortunately, if you have a locale with non-english transliteration rule as I18n default (say, :ru that may return any of [:one, :few, :many, :other]), then enable I18n fallback and use :en locale as current, Pluralization module will look up for pluralize lambda in current locale, fallback to :ru, use russian pluralization rule and fail miserably with simple :en translations (such as the ones shipped with Rails).

Now, regarding the fix.. It seems that we can't really tell if we are receiving a translation that was fallback'd, so, basically two options that come to mind (probably there is a perfect solution, but I'm not there yet):

  1. Load :en pluralization rule when enabling Pluralization module. That one is a bit stupid, because that won't fix anything on :en-US locale, and basically with every other locale that shares a pluralization rule with English.
  2. Have a key when using translations that can be taken into account by Fallbacks module (fallbacks.rb L38): this way, we can just immideately cancel searching for a translation and return the result for current locale only. I'm not sure if options[:fallback] does exactly this — seems that it is done for a different purpose of not going deep into recursive fallbacks when falling back to search at least one locale with the key. Anywho, we can document options[:fallback] or introduce options[:no_fallback](TBD naming): it's does not make much sence that options[:fallback] when set to true will skip callbacks and not vice verca.

Can implement both fixes but we probably gotta talk about this first. /cc @svenfuchs, @clemens?

@ghost ghost assigned svenfuchs Nov 21, 2011
@yaroslav
Copy link
Collaborator Author

/cc @josevalim

@sashazykov
Copy link

Please, fix this bug.

@kirs
Copy link

kirs commented Oct 23, 2013

We still have this issue in 0.6.5.
@josevalim @svenfuchs any ideas?

@sponomarev
Copy link

check this, please!

@radar
Copy link
Collaborator

radar commented Nov 20, 2016

I would accept a PR to fix this issue.

@radar radar added this to the 0.9.0 milestone Nov 20, 2016
@radar radar modified the milestones: 0.9.0, 0.10.0 Oct 1, 2017
@Matt-Yorkley
Copy link

Did this ever get fixed..?

@radar
Copy link
Collaborator

radar commented Nov 18, 2020

@Matt-Yorkley The card's still open, so I am guessing not.

@papa-cool
Copy link

We have many open cards for the same issue.
svenfuchs/rails-i18n#893
#493

I've already proposed a fix which has been closed without any explanation. It's a pity.
#502

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

8 participants