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:
parent
1f4a541421
commit
d4ad739454
7 changed files with 16 additions and 16 deletions
|
@ -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*
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
# <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
|
||||
# <tt>translate</tt>.
|
||||
#
|
||||
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue