'Disable loading of nested locale (I18n) folders in Rails 7

After upgrading from Rails 6 to Rails 7, there seems to be a not-yet-fully-documented change in how I18n loads the config files. In Rails 7, files in subfolders (config/locales/<folder>/* are loaded as well, whereas in Rails 6 they were not loaded.

The documentation still states:

The default locale loading mechanism in Rails does not load locale files in nested dictionaries

I was able to find this post where it states that Rails 7 does load nested folders (which is the behavior I see), as well as this Rails PR that is on subject.

I believe the piece of code responsible for this, is in rails/railties/lib/rails/engine/configuration.rb:

paths.add "config/locales",      glob: "**/*.{rb,yml}"

I would like to revert to the old behavior, of only loading the files directly under the locales folder, or at least be able to blacklist some subfolders. Is this possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source