1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated Rails.config.action_view.raise_on_missing_translations

This commit is contained in:
Rafael Mendonça França 2021-10-14 22:09:03 +00:00
parent 1f4a541421
commit d4ad739454
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
7 changed files with 16 additions and 16 deletions

View file

@ -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`. * Remove deprecated support to passing a path to `fixture_file_upload` relative to `fixture_path`.
*Rafael Mendonça França* *Rafael Mendonça França*

View file

@ -156,9 +156,6 @@ module ActionView # :nodoc:
# Specify default_formats that can be rendered. # Specify default_formats that can be rendered.
cattr_accessor :default_formats 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 # Specify whether submit_tag should automatically disable on click
cattr_accessor :automatically_disable_submit_tag, default: true cattr_accessor :automatically_disable_submit_tag, default: true

View file

@ -11,6 +11,9 @@ module ActionView
include TagHelper include TagHelper
# Specify whether an error should be raised for missing translations
singleton_class.attr_accessor :raise_on_missing_translations
included do included do
mattr_accessor :debug_missing_translation, default: true mattr_accessor :debug_missing_translation, default: true
end end
@ -37,7 +40,7 @@ module ActionView
# #
# If you would prefer missing translations to raise an error, you can # If you would prefer missing translations to raise an error, you can
# opt out of span-wrapping behavior globally by setting # opt out of span-wrapping behavior globally by setting
# <tt>ActionView::Base.raise_on_missing_translations = true</tt> or # <tt>config.i18n.raise_on_missing_translations = true</tt> or
# individually by passing <tt>raise: true</tt> as an option to # individually by passing <tt>raise: true</tt> as an option to
# <tt>translate</tt>. # <tt>translate</tt>.
# #
@ -75,7 +78,7 @@ module ActionView
options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)] options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]
end 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 default = MISSING_TRANSLATION
translation = while key || alternatives.present? translation = while key || alternatives.present?

View file

@ -57,12 +57,6 @@ module ActionView
config.after_initialize do |app| config.after_initialize do |app|
ActiveSupport.on_load(:action_view) do ActiveSupport.on_load(:action_view) do
app.config.action_view.each do |k, v| 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 send "#{k}=", v
end end
end end

View file

@ -118,22 +118,22 @@ class TranslationHelperTest < ActiveSupport::TestCase
end end
def test_raises_missing_translation_message_with_raise_config_option 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 assert_raise(I18n::MissingTranslationData) do
translate("translations.missing") translate("translations.missing")
end end
ensure ensure
ActionView::Base.raise_on_missing_translations = false ActionView::Helpers::TranslationHelper.raise_on_missing_translations = false
end end
def test_raise_arg_overrides_raise_config_option 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" expected = "translation missing: en.translations.missing"
assert_equal expected, translate(:"translations.missing", raise: false) assert_equal expected, translate(:"translations.missing", raise: false)
ensure ensure
ActionView::Base.raise_on_missing_translations = false ActionView::Helpers::TranslationHelper.raise_on_missing_translations = false
end end
def test_raises_missing_translation_message_with_raise_option def test_raises_missing_translation_message_with_raise_option

View file

@ -77,7 +77,7 @@ module I18n
def self.forward_raise_on_missing_translations_config(app) def self.forward_raise_on_missing_translations_config(app)
ActiveSupport.on_load(:action_view) do 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 end
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do

View file

@ -71,6 +71,8 @@ Please refer to the [Changelog][action-view] for detailed changes.
### Removals ### Removals
* Remove deprecated `Rails.config.action_view.raise_on_missing_translations`.
### Deprecations ### Deprecations
### Notable changes ### Notable changes