-
-
Couldn't load subscription status.
- Fork 115
Description
Describe the bug
When using the i18n adapter as a message backend, I18n.available_locales gets mutated and English is added as an available locale.
dry-schema looks into it's load paths, finds the English locale file it ships with, and adds English as available locale to I18n.
This is a rather surprising side effect I did not expect. In our application, I18n.available_locales is the source of truth for which locales our application supports. We configure this very explicitly in a Rails initializer
and we rely on it to stay as it is. A gem should not simply alter the available locales. At least not without any warnings.
To Reproduce
- Use i18n as a message backend
- Configure English to be excluded from
I18n.available_localesin a (Rails) initializer - Create a schema with
dry-schema I18n.available_localesnow includes:en
Expected behavior
I18n.available_locales is not altered.
My environment
- Ruby 3.4.2
- dry-schema 1.13.4
Workaround
Right now, my workaround is to empty the dry-schema messages load path if the application is not supposed to support English.
Source of the issue
lib/dry/schema/messages/i18n.rb:124