Bug: Pluralization and Fallbacks modules do not play well together
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- ruby
- Domain
- internationalization
Research direction
Read Backend::Pluralization’s pluralizer path and Fallbacks, especially fallbacks.rb line 38. Reproduce the reported :en current-locale and :ru fallback interaction, then resolve which proposed fallback or rule-loading behavior is intended. Done means the chosen behavior is agreed and the simple :en translation case no longer fails.
Written by the indexing model from the issue text.
Description
Related (RU, may want to use Google Translate): https://github.com/yaroslav/russian/issues/29#issuecomment-2693629
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):
- 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.
- 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?
- Dominant language
- Ruby
- Stars
- 1k
- Forks
- 415
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby-i18n/i18n
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
ICU support Open
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Similar issues
-
バグ
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
voxpupuli/puppet-epel#186 · 1 comment ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) OpenBug Frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TheOdinProject/curriculum#31402 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100