From 1696dd2de64ea826a16787c3de9c780d4eef1f95 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 18 Mar 2026 13:58:17 +1100 Subject: [PATCH] DRY language fallback config --- config/application.rb | 7 +++++-- config/environments/development.rb | 2 -- config/environments/production.rb | 4 ---- config/environments/staging.rb | 4 ---- config/environments/test.rb | 3 --- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/config/application.rb b/config/application.rb index 71f47829ff..506430dc1f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -158,12 +158,15 @@ module Openfoodnetwork # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # The default locale is set in the environment. config.i18n.default_locale = OpenFoodNetwork::I18nConfig.default_locale config.i18n.available_locales = OpenFoodNetwork::I18nConfig.available_locales I18n.locale = config.i18n.locale = config.i18n.default_locale + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = [:en] + # Calculate digests for locale files so we can know when they change I18nDigests.build_digests config.i18n.available_locales diff --git a/config/environments/development.rb b/config/environments/development.rb index 0aa1a6eda6..bfc893d885 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -111,8 +111,6 @@ Rails.application.configure do # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true - config.i18n.fallbacks = [:en] - # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true diff --git a/config/environments/production.rb b/config/environments/production.rb index ff8394a821..95ebad2351 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -91,10 +91,6 @@ Rails.application.configure do # Use https in email links config.action_mailer.default_url_options = { protocol: 'https' } - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = [:en] - # Send deprecation notices to registered listeners config.active_support.deprecation = :notify diff --git a/config/environments/staging.rb b/config/environments/staging.rb index b344d4446e..2d28f49a7f 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -60,10 +60,6 @@ Openfoodnetwork::Application.configure do # Enable threaded mode # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = [:en] - # Send deprecation notices to registered listeners config.active_support.deprecation = :notify end diff --git a/config/environments/test.rb b/config/environments/test.rb index 59f7215aad..089170d2a2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -89,9 +89,6 @@ Rails.application.configure do # Raises error for missing translations. config.i18n.raise_on_missing_translations = true - # Tests assume English text on the site. - config.i18n.fallbacks = [:en] - # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true