diff options
author | José Valim <jose.valim@gmail.com> | 2009-02-01 09:43:39 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-02-02 17:56:22 +0100 |
commit | 2ecc678ed6ab60c1bdc7dce67c0c908542c5008d (patch) | |
tree | fbff29a324181432279363bb229f62bf8d345d4b /actionpack/lib/action_controller/rescue.rb | |
parent | beca1f2e151558ded3d5a4efebd328ab2533edc6 (diff) | |
download | rails-2ecc678ed6ab60c1bdc7dce67c0c908542c5008d.tar.gz rails-2ecc678ed6ab60c1bdc7dce67c0c908542c5008d.tar.bz2 rails-2ecc678ed6ab60c1bdc7dce67c0c908542c5008d.zip |
Added localized rescue (404.da.html) [#1835 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'actionpack/lib/action_controller/rescue.rb')
-rw-r--r-- | actionpack/lib/action_controller/rescue.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 4b7d1e32fd..ec61715b57 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -99,13 +99,19 @@ module ActionController #:nodoc: # Attempts to render a static error page based on the # <tt>status_code</tt> thrown, or just return headers if no such file - # exists. For example, if a 500 error is being handled Rails will first - # attempt to render the file at <tt>public/500.html</tt>. If the file - # doesn't exist, the body of the response will be left empty. + # exists. At first, it will try to render a localized static page. + # For example, if a 500 error is being handled Rails and locale is :da, + # it will first attempt to render the file at <tt>public/500.da.html</tt> + # then attempt to render <tt>public/500.html</tt>. If none of them exist, + # the body of the response will be left empty. def render_optional_error_file(status_code) status = interpret_status(status_code) - path = "#{Rails.public_path}/#{status.to_s[0,3]}.html" - if File.exist?(path) + locale_path = "#{Rails.public_path}/#{status[0,3]}.#{I18n.locale}.html" if I18n.locale + path = "#{Rails.public_path}/#{status[0,3]}.html" + + if locale_path && File.exist?(locale_path) + render :file => locale_path, :status => status, :content_type => Mime::HTML + elsif File.exist?(path) render :file => path, :status => status, :content_type => Mime::HTML else head status |