提交 eb32b365 编写于 作者: C Carlos Antonio da Silva

Merge pull request #9753 from jbarreneche/bug/render-locale-fallbacks

i18n locale fallback for localized views
## 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.
......
......@@ -43,7 +43,13 @@ def initialize_details(details)
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 }
......
......@@ -25,4 +25,13 @@ def test_default_locale_template_is_used_when_locale_is_missing
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册