Closed jeffblake closed 2 years ago
Hey @jeffblake, sorry for the troubles you're encountering here.
I've just tried to reproduce this in a new Rails application, and I wasn't able to successfully do it:
irb(main):001:0> I18n.locale # => :en
=> :en
irb(main):002:0> Product::Ticket.model_name.human # => Ticket
[i18n-debug] en.activerecord.models.product/ticket => {:one=>"Ticket"}
=> "Ticket"
irb(main):003:0> I18n.locale = :'en-US'
irb(main):004:0> Product::Ticket.model_name.human # => Product
[i18n-debug] en-US.activerecord.models.product/ticket => nil
[i18n-debug] en.activerecord.models.product/ticket => {:one=>"Ticket"}
=> "Ticket"
irb(main):005:0> I18n.fallbacks
=> {:en=>[:en], :"en-US"=>[:"en-US", :en]}
I can confirm I've enabled fallbacks and the translation file is the same. In terms of gems, I've got these relevant ones installed:
* i18n (1.9.1)
* i18n-debug (1.2.0)
* rails-i18n (7.0.1)
* rails (6.1.4.4)
Could you please put an app up on GitHub that reproduces this issue? I think that would help me to track this down.
Thanks!
Here is the repro: https://github.com/jeffblake/i18n-bug
Thank you. I was now able to reproduce this issue. The script I'm using for this reproduction is this:
p I18n.locale # => :en
puts "Expecting 'Ticket'"
puts "Actual: #{Product::Ticket.model_name.human}" # => Product
p I18n.locale = :'en-US'
puts "Expecting 'Ticket'"
puts "Actual: #{Product::Ticket.model_name.human}" # => Product
p I18n.fallbacks
And I run it with:
bundle exec rails runner repro.rb
It looks like it was a regression in 1.9, as I am unable to reproduce the failure with 1.8.11. I'll try to find that commit that broke this.
Looks like this might be the commit: fe72c0f5bfdb9a91039bede931a1652208dd63ec.
commit fe72c0f5bfdb9a91039bede931a1652208dd63ec
Author: Michael Overmeyer <michael.overmeyer@shopify.com>
Date: Wed Dec 15 15:55:02 2021 -0500
Resolve `Symbol`s using the original fallback locale
lib/i18n.rb | 1 +
lib/i18n/backend/fallbacks.rb | 13 +++++++++-
lib/i18n/tests/localization/procs.rb | 1 +
lib/i18n/tests/procs.rb | 8 +++++-
test/backend/fallbacks_test.rb | 48 ++++++++++++++++++++++++++++++++++++
Thanks for finding it, hopefully we can get a fix soon, it's causing a headache for a lot of my customers.
Hey @movermeyer :wave: I'm going to revert the above commit (from #591), and add a regression test in for #617 in a separate PR.
Could you please investigate a way that we could make #617 and your work on #591 work in harmony?
What I tried to do
In application.rb:
config.i18n.fallbacks = true
In
en.yml
:In console:
What I expected to happen
Product::Ticket.model_name.human returns
Ticket
in any other language, i.e. uses theen
fallbackThe lookup chain is wrong (using I18n-debug gem):
Versions of i18n, rails, and anything else you think is necessary
Bonus points for providing an application or a small code example which reproduces the issue.
Thanks! :heart: