Closed yheuhtozr closed 1 year ago
Notably, this happens in Rails 6.1 and Rails 6.0 as well.
I got the same issue, do you know how to solve it?
It only happened with Rails 7
The issue is still present. I wonder why the MR was reverted.
Fallbacks are impossible to configure with ruby-i18n 1.14.1 (tested on rails 7.1.3).
Here is a reproducible script:
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "~> 7.1"
gem "i18n", "1.14.1"
end
require "active_support/railtie"
require "minitest/autorun"
class TestApp < Rails::Application
config.load_defaults 7.1
config.eager_load = false
config.i18n.default_locale = :en
config.i18n.available_locales = [:'en-GB', :'en-UK', :'en-US', :en]
config.i18n.fallbacks = { :'en-GB' => [:en], :'en-UK' => [:en], :'en-US' => [:en] }
# not working either
# config.i18n.fallbacks = [:'en-US', :en]
# config.i18n.fallbacks.map = { :'en-GB' => [:en], :'en-UK' => [:en], :'en-US' => [:en] }
# makes the test pass
# I18n.fallbacks = { :'en-GB' => [:en], :'en-UK' => [:en], :'en-US' => [:en], :en => [:en] }
end
Rails.application.initialize!
class I18nFallbacksTest < ActiveSupport::TestCase
test "fallbacks" do
assert_not_empty I18n.fallbacks
end
end
What I tried to do
What I expected to happen
What actually happened
Versions of i18n, rails, and anything else you think is necessary
Workaround
https://github.com/ruby-i18n/i18n/blob/fbc9b2b502ec373519d45a7b6da4ddc9243404c4/lib/i18n/locale/fallbacks.rb#L67-L80
It seems to work
as expected[^1] if you add one line between the line 76-77 as follows:[^1]: not exactly, it'll be like
{:"en-AU"=>[:"en-GB", :"en-US", :en], :en=>[:en]}