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] Providing a hash to fallbacks with a default does not set I18n.fallbacks.defaults #567

Open
sergioisidoro opened this issue May 11, 2021 · 0 comments

Comments

@sergioisidoro
Copy link

Hello,

I'm not sure how to categorise this, as if a bug or a feature request, but certainly it is a bit of a missed expectation of how the fallback map / hash assignment worked :) And I'm leaving it here also as a reference for people to find.

What I tried to do

In a Rails environment:

language_fallbacks = {
  "en-US": [:en],
  "es-US": [:es, :en],
}

language_fallbacks.default = [:en]
...

config.i18n.fallbacks = language_fallbacks

What I expected to happen

I was expecting that providing a hash with default to I18n.fallbacks.map would automatically populate the I18n.fallbacks.defaults

What actually happened

I still got the Rails deprecation warning DEPRECATION WARNING: Using I18n fallbacks with an empty defaults sets the defaults to include the default_locale (...), meaning that fallbacks defaults was left empty.

And I needed to explicitly assign the defaults:

language_fallbacks = {
  "en-US": [:en],
  "es-US": [:es, :en],
}

language_fallbacks.default = [:en]
...

config.i18n.fallbacks.map = language_fallbacks
config.i18n.fallbacks.defaults = language_fallbacks.default

Versions of i18n, rails, and anything else you think is necessary

gem 'rails-i18n', '~> 6.0.0'
gem 'i18n', '1.8.5'

In rails 6.0

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

1 participant