diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 25d444a120..ffd0af69e9 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Remove deprecated `Rails.config.action_view.raise_on_missing_translations`.
+
+ *Rafael Mendonça França*
+
* Remove deprecated support to passing a path to `fixture_file_upload` relative to `fixture_path`.
*Rafael Mendonça França*
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index d18b1b0c28..15040dd841 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -156,9 +156,6 @@ module ActionView # :nodoc:
# Specify default_formats that can be rendered.
cattr_accessor :default_formats
- # Specify whether an error should be raised for missing translations
- cattr_accessor :raise_on_missing_translations, default: false
-
# Specify whether submit_tag should automatically disable on click
cattr_accessor :automatically_disable_submit_tag, default: true
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index fa4e082114..d721ccd7df 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -11,6 +11,9 @@ module ActionView
include TagHelper
+ # Specify whether an error should be raised for missing translations
+ singleton_class.attr_accessor :raise_on_missing_translations
+
included do
mattr_accessor :debug_missing_translation, default: true
end
@@ -37,7 +40,7 @@ module ActionView
#
# If you would prefer missing translations to raise an error, you can
# opt out of span-wrapping behavior globally by setting
- # ActionView::Base.raise_on_missing_translations = true or
+ # config.i18n.raise_on_missing_translations = true or
# individually by passing raise: true as an option to
# translate.
#
@@ -75,7 +78,7 @@ module ActionView
options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]
end
- options[:raise] = true if options[:raise].nil? && ActionView::Base.raise_on_missing_translations
+ options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations
default = MISSING_TRANSLATION
translation = while key || alternatives.present?
diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb
index df9b96524a..90fe31705b 100644
--- a/actionview/lib/action_view/railtie.rb
+++ b/actionview/lib/action_view/railtie.rb
@@ -57,12 +57,6 @@ module ActionView
config.after_initialize do |app|
ActiveSupport.on_load(:action_view) do
app.config.action_view.each do |k, v|
- if k == :raise_on_missing_translations
- ActiveSupport::Deprecation.warn \
- "action_view.raise_on_missing_translations is deprecated and will be removed in Rails 7.0. " \
- "Set i18n.raise_on_missing_translations instead. " \
- "Note that this new setting also affects how missing translations are handled in controllers."
- end
send "#{k}=", v
end
end
diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb
index a63671541b..9ed034113d 100644
--- a/actionview/test/template/translation_helper_test.rb
+++ b/actionview/test/template/translation_helper_test.rb
@@ -118,22 +118,22 @@ class TranslationHelperTest < ActiveSupport::TestCase
end
def test_raises_missing_translation_message_with_raise_config_option
- ActionView::Base.raise_on_missing_translations = true
+ ActionView::Helpers::TranslationHelper.raise_on_missing_translations = true
assert_raise(I18n::MissingTranslationData) do
translate("translations.missing")
end
ensure
- ActionView::Base.raise_on_missing_translations = false
+ ActionView::Helpers::TranslationHelper.raise_on_missing_translations = false
end
def test_raise_arg_overrides_raise_config_option
- ActionView::Base.raise_on_missing_translations = true
+ ActionView::Helpers::TranslationHelper.raise_on_missing_translations = true
expected = "translation missing: en.translations.missing"
assert_equal expected, translate(:"translations.missing", raise: false)
ensure
- ActionView::Base.raise_on_missing_translations = false
+ ActionView::Helpers::TranslationHelper.raise_on_missing_translations = false
end
def test_raises_missing_translation_message_with_raise_option
diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb
index 094f65ad6c..1e7185e950 100644
--- a/activesupport/lib/active_support/i18n_railtie.rb
+++ b/activesupport/lib/active_support/i18n_railtie.rb
@@ -77,7 +77,7 @@ module I18n
def self.forward_raise_on_missing_translations_config(app)
ActiveSupport.on_load(:action_view) do
- self.raise_on_missing_translations = app.config.i18n.raise_on_missing_translations
+ ActionView::Helpers::TranslationHelper.raise_on_missing_translations = app.config.i18n.raise_on_missing_translations
end
ActiveSupport.on_load(:action_controller) do
diff --git a/guides/source/7_0_release_notes.md b/guides/source/7_0_release_notes.md
index 51bed7abaf..2787528a65 100644
--- a/guides/source/7_0_release_notes.md
+++ b/guides/source/7_0_release_notes.md
@@ -71,6 +71,8 @@ Please refer to the [Changelog][action-view] for detailed changes.
### Removals
+* Remove deprecated `Rails.config.action_view.raise_on_missing_translations`.
+
### Deprecations
### Notable changes