diff options
author | Kassio Borges <kassioborgesm@gmail.com> | 2014-01-26 20:05:34 -0200 |
---|---|---|
committer | Kassio Borges <kassioborgesm@gmail.com> | 2014-01-27 08:03:46 -0200 |
commit | 433628a45c2f5dd04b115af1b5579dac75255c67 (patch) | |
tree | 891bdb430900df8509d71ed67a78f5fd95c5cda5 /actionview/lib | |
parent | 3fd6329e2bda3b5e01cab90527fe5d09e21f3b9f (diff) | |
download | rails-433628a45c2f5dd04b115af1b5579dac75255c67.tar.gz rails-433628a45c2f5dd04b115af1b5579dac75255c67.tar.bz2 rails-433628a45c2f5dd04b115af1b5579dac75255c67.zip |
Rails config for raise on missing translations
Add a config to setup whether raise exception for missing translation or
not.
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/base.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/translation_helper.rb | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb index 8eb7072d0c..455ce531ae 100644 --- a/actionview/lib/action_view/base.rb +++ b/actionview/lib/action_view/base.rb @@ -153,6 +153,10 @@ 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 + @@raise_on_missing_translations = false + class_attribute :_routes class_attribute :logger diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index 3ae1df04fe..0bc40874d9 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -38,10 +38,10 @@ module ActionView # If the user has specified rescue_format then pass it all through, otherwise use # raise and do the work ourselves - if options.key?(:raise) || options.key?(:rescue_format) - raise_error = options[:raise] || options[:rescue_format] - else - raise_error = false + options[:raise] ||= ActionView::Base.raise_on_missing_translations + + raise_error = options[:raise] || options.key?(:rescue_format) + unless raise_error options[:raise] = true end |