diff options
author | Shota Fukumori (sora_h) <her@sorah.jp> | 2013-12-04 12:48:21 +0900 |
---|---|---|
committer | Shota Fukumori <sorah@cookpad.com> | 2013-12-05 09:20:58 +0900 |
commit | c1d5477b63e73dadec9f284fa55ec22d81f3bf36 (patch) | |
tree | 05f338e912a29ec109e7f2d94af85ac6451e8fdf /actionview/lib | |
parent | 49ed8a1a628ff8b7aa089df241cd3f487cfbd06f (diff) | |
download | rails-c1d5477b63e73dadec9f284fa55ec22d81f3bf36.tar.gz rails-c1d5477b63e73dadec9f284fa55ec22d81f3bf36.tar.bz2 rails-c1d5477b63e73dadec9f284fa55ec22d81f3bf36.zip |
Escalate missing error when :raise is true
Before ec16ba75a5493b9da972eea08bae630eba35b62f,
ActionView::Helpers::TranslationHelper#translate has raised errors with
specifying options[:raise] to true.
This should work by this fix:
begin
t(:"translations.missing", raise: true)
rescue I18n::MissingTranslationData
p :hello!
end
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/helpers/translation_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index a1a2bebb6e..3ae1df04fe 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -38,7 +38,13 @@ module ActionView # If the user has specified rescue_format then pass it all through, otherwise use # raise and do the work ourselves - options[:raise] = true unless options.key?(:raise) || options.key?(:rescue_format) + if options.key?(:raise) || options.key?(:rescue_format) + raise_error = options[:raise] || options[:rescue_format] + else + raise_error = false + options[:raise] = true + end + if html_safe_translation_key?(key) html_safe_options = options.dup options.except(*I18n::RESERVED_KEYS).each do |name, value| @@ -53,6 +59,8 @@ module ActionView I18n.translate(scope_key_by_partial(key), options) end rescue I18n::MissingTranslationData => e + raise e if raise_error + keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]) content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}") end |