spree-contrib / spree_i18n

I18n translation files for Spree Commerce.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
348 stars 762 forks source link

i18n fallbacks should not be overridden #904

Open kreba opened 2 years ago

kreba commented 2 years ago

Thank you for your work on this valuable gem :pray:

We are translating our application to many locales and we want our default_locale to be :de-CH, but we still want to ultimately fall back to :en because this is Spree's master locale.

So we want to configure app.config.i18n.fallbacks = [:de, :en]

However, the initializer spree_i18n.environment sets app.config.i18n.fallbacks = true, thus replacing any previous fallback configuration. https://github.com/spree-contrib/spree_i18n/blob/be00bcdd0f272aa6815de87d6c7917ed5627fcbd/lib/spree_i18n/engine.rb#L19

Please change this to app.config.i18n.fallbacks ||= true (note the ||=) so our application can configure its own fallbacks.

Possible workaround for now: Our application can configure the fallbacks in a config.after_initialize do ... end block. That seems to do the trick. But we can't be sure that spree_i18n's initialization works as intended if we do this.