aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-03-18 09:14:15 -0700
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-03-18 09:14:15 -0700
commiteb32b3659d3ead36e66efe8ef2ced126110311a4 (patch)
tree9a094954b449f9ce4f8960eb601d544a1f9314f6 /actionpack
parent4e7292c0262ae70d968e0732bb6fea627646feef (diff)
parentcecbf5dd4d814f0bbd6a7c77a7c550c90a75cf47 (diff)
downloadrails-eb32b3659d3ead36e66efe8ef2ced126110311a4.tar.gz
rails-eb32b3659d3ead36e66efe8ef2ced126110311a4.tar.bz2
rails-eb32b3659d3ead36e66efe8ef2ced126110311a4.zip
Merge pull request #9753 from jbarreneche/bug/render-locale-fallbacks
i18n locale fallback for localized views
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/lib/action_view/lookup_context.rb8
-rw-r--r--actionpack/test/controller/localized_templates_test.rb9
3 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index b23d0668d3..69096443fe 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Include I18n locale fallbacks in view lookup.
+ Fixes GH#3512.
+
+ *Juan Barreneche*
+
* Integration and functional tests allow headers and rack env
variables to be passed when performing requests.
Fixes #6513.
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb
index 4e4816d983..d61cc0f304 100644
--- a/actionpack/lib/action_view/lookup_context.rb
+++ b/actionpack/lib/action_view/lookup_context.rb
@@ -43,7 +43,13 @@ module ActionView
module Accessors #:nodoc:
end
- register_detail(:locale) { [I18n.locale, I18n.default_locale].uniq }
+ register_detail(:locale) do
+ locales = [I18n.locale]
+ locales.concat(I18n.fallbacks[I18n.locale]) if I18n.respond_to? :fallbacks
+ locales << I18n.default_locale
+ locales.uniq!
+ locales
+ end
register_detail(:formats) { ActionView::Base.default_formats || [:html, :text, :js, :css, :xml, :json] }
register_detail(:handlers){ Template::Handlers.extensions }
diff --git a/actionpack/test/controller/localized_templates_test.rb b/actionpack/test/controller/localized_templates_test.rb
index bac1d02977..6b02eedaed 100644
--- a/actionpack/test/controller/localized_templates_test.rb
+++ b/actionpack/test/controller/localized_templates_test.rb
@@ -25,4 +25,13 @@ class LocalizedTemplatesTest < ActionController::TestCase
ensure
I18n.locale = old_locale
end
+
+ def test_use_fallback_locales
+ I18n.locale = :"de-AT"
+ I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
+ I18n.fallbacks[:"de-AT"] = [:de]
+
+ get :hello_world
+ assert_equal "Gutten Tag", @response.body
+ end
end