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

update I18n fallbacks configuration to be compatible with i18n 1.1.0 #33574

Conversation

lsylvester
Copy link
Contributor

In I18n 1.1.0, there was a change to no longer include the default locale as a default fallback.

As a result, this broke the tests for Rails, and in #33566 we avoided using it in order to get the tests to pass again.

This PR attempt to provide a permanent solution for compatibility with I18n 1.1.0.

When config.i18n.fallbacks = true Rails would set the fallback defaults to [] relying on I18n to add the default locale into the fallbacks. As I18n no longer does this, Rails will now explicitly set the fallback defaults to the current locale.

Where config.i18n.fallbacks is a Hash or config.i18n.fallbacks.map is set, I18n would also be setting the default to the current locale, but that was not documented as part of Rails, and may have been unexpected behaviour. I have maintained this behaviour by explicitly adding in the current locale to the defaults, and added a depreciation message so that it can be removed in the future.

In the case were no fallbacks were configured Rails would not include the Fallbacks module in the backend, so it appears to behave correctly across both versions of i18n.

@rails-bot
Copy link

r? @kamipo

(@rails-bot has picked a reviewer for you, use r? to override)

if args.empty? || args.first.is_a?(Hash)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Using I18n fallbacks with an empty `defaults` sets the defaults to
include the `defalt_locale`. This behaviour will change in Rails 6.1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change behaviour to behavior per our documentation requirements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo in the defalt_locale -> default_locale

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileencodes @Edouard-chin I have made the suggested changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsylvester I think you forgot to push.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca Thanks for letting me know. Sorry about that. Should be fixed now.

@lsylvester lsylvester force-pushed the change-i18n-defaults-behaviour-to-match-i18n-1.1.0 branch 2 times, most recently from 7f47abd to 21f4c13 Compare August 13, 2018 23:08
mejackreed added a commit to projectblacklight/spotlight that referenced this pull request Aug 14, 2018
camillevilla pushed a commit to projectblacklight/spotlight that referenced this pull request Aug 14, 2018
* auto gen rubocop todo for latest updates

* Disable specify inverse_of rule for now, until further investigation

* pin i18n until Rails and i18n can sort out compatibility rails/rails#33574
cbeer pushed a commit to projectblacklight/spotlight that referenced this pull request Aug 15, 2018
* auto gen rubocop todo for latest updates

* Disable specify inverse_of rule for now, until further investigation

* pin i18n until Rails and i18n can sort out compatibility rails/rails#33574
@lsylvester lsylvester force-pushed the change-i18n-defaults-behaviour-to-match-i18n-1.1.0 branch from 21f4c13 to 66614f6 Compare August 22, 2018 20:56
@rafaelfranca rafaelfranca merged commit 62a0c30 into rails:master Sep 6, 2018
rafaelfranca added a commit that referenced this pull request Sep 6, 2018
…our-to-match-i18n-1.1.0

update I18n fallbacks configuration to be compatible with i18n 1.1.0
rafaelfranca added a commit that referenced this pull request Sep 6, 2018
…our-to-match-i18n-1.1.0

update I18n fallbacks configuration to be compatible with i18n 1.1.0
pixeltrix pushed a commit that referenced this pull request Oct 27, 2018
…our-to-match-i18n-1.1.0

update I18n fallbacks configuration to be compatible with i18n 1.1.0
@schuetzm
Copy link
Contributor

Is there a way to silence this deprecation message if you want to opt-in to the new behaviour?

@rafaelfranca
Copy link
Member

Not really, but we should have. Can you take a look? Maybe we can add another config to disable that deprecation.

@schuetzm
Copy link
Contributor

@rafaelfranca See here: #35052

suketa added a commit to suketa/rails_sandbox that referenced this pull request May 20, 2019
rails/rails#33574
update I18n fallbacks configuration to be compatible with i18n 1.1.0
suketa added a commit to suketa/rails_sandbox that referenced this pull request May 23, 2019
update I18n fallbacks configuration to be compatible with i18n 1.1.0
rails/rails#33574

Describe how to silence the deprecation warning about empty I18n
fallbacks
rails/rails#35052
suketa added a commit to suketa/rails_sandbox that referenced this pull request May 24, 2019
update I18n fallbacks configuration to be compatible with i18n 1.1.0
rails/rails#33574

Describe how to silence the deprecation warning about empty I18n
fallbacks
rails/rails#35052
elrayle added a commit to cul-it/exhibits-library-cornell-edu that referenced this pull request Apr 5, 2020
* spotlight version updated to v2.2.0
  * make several changes to fix the build, including updating our Rubocop todo, and requiring i18n < 1.1 as i18n introduced a backwards incompatible change with Rails (rails/rails#33574)
  * Updates our CI to build with Rails 5.2.1
  * adds new locale files for Chinese and Italian languages
  * Update the PaperTrails versions table to be larger to accommodate large Spotlight::Page
  * Uses textarea for free form text input
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

Successfully merging this pull request may close these issues.

7 participants