feat: allow default locale to be set via DEFAULT_LOCALE env var#839
feat: allow default locale to be set via DEFAULT_LOCALE env var#839rewritten wants to merge 1 commit intocoopdevs:developfrom
Conversation
Resolves coopdevs#838 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds support for configuring the Rails app’s default I18n locale via an environment variable, keeping the existing :es default when unset.
Changes:
- Replace hardcoded
config.i18n.default_locale = :eswithENV.fetch('DEFAULT_LOCALE', 'es').to_sym.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| config.i18n.default_locale = ENV.fetch('DEFAULT_LOCALE', 'es').to_sym | ||
| config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR', :fr, :ja] |
There was a problem hiding this comment.
DEFAULT_LOCALE is converted directly to a symbol and used as default_locale without validation. If the env var is set to an unsupported/blank value (not in config.i18n.available_locales on the next line), this can cause boot-time I18n::InvalidLocale errors (or silently misconfigure locale selection). Consider normalizing and validating the env value against available_locales, and falling back to :es (optionally logging a warning) when it's not allowed.
| config.i18n.default_locale = ENV.fetch('DEFAULT_LOCALE', 'es').to_sym | |
| config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR', :fr, :ja] | |
| config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR', :fr, :ja] | |
| default_locale_env = ENV['DEFAULT_LOCALE'].to_s.strip | |
| default_locale = default_locale_env.empty? ? nil : default_locale_env.to_sym | |
| config.i18n.default_locale = config.i18n.available_locales.include?(default_locale) ? default_locale : :es |
|
@rewritten It misses docs, as we did in #833 and update from develop (conflitcs). |
Summary
:esdefault locale withENV.fetch('DEFAULT_LOCALE', 'es').to_symeswhen the env var is not set, so no behaviour change for existing deploymentsALLOWED_HOSTSpattern in the same fileResolves #838
🤖 Generated with Claude Code