mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ignore scope in missing translation input.
It's already represented in the key name. Demonstrate with a test. Also test that the default isn't output.
This commit is contained in:
parent
367e483229
commit
0fb2d1a0ba
2 changed files with 9 additions and 1 deletions
|
@ -90,7 +90,7 @@ module ActionView
|
|||
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
|
||||
title = "translation missing: #{keys.join('.')}"
|
||||
|
||||
interpolations = options.except(:default)
|
||||
interpolations = options.except(:default, :scope)
|
||||
if interpolations.any?
|
||||
title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(', ')
|
||||
end
|
||||
|
|
|
@ -66,6 +66,14 @@ class TranslationHelperTest < ActiveSupport::TestCase
|
|||
assert translate(:"translations.missing").html_safe?
|
||||
end
|
||||
|
||||
def test_returns_missing_translation_message_does_filters_out_i18n_options
|
||||
expected = '<span class="translation_missing" title="translation missing: en.translations.missing, year: 2015">Missing</span>'
|
||||
assert_equal expected, translate(:"translations.missing", year: '2015', default: [])
|
||||
|
||||
expected = '<span class="translation_missing" title="translation missing: en.scoped.translations.missing, year: 2015">Missing</span>'
|
||||
assert_equal expected, translate(:"translations.missing", year: '2015', scope: %i(scoped))
|
||||
end
|
||||
|
||||
def test_raises_missing_translation_message_with_raise_config_option
|
||||
ActionView::Base.raise_on_missing_translations = true
|
||||
|
||||
|
|
Loading…
Reference in a new issue