diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2013-03-14 14:07:19 -0700 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2013-03-14 14:07:19 -0700 |
commit | 9d5699a05ca625d531988d563d2eda7e4b290fed (patch) | |
tree | 276b32e41b91871da8a86dbf85ae83608cd09ddd /actionpack | |
parent | 3d4d7420ae43a35ae01343ced6d7c685d0b667ee (diff) | |
parent | ce755697fc926b7fa5c783a27ca814574045c961 (diff) | |
download | rails-9d5699a05ca625d531988d563d2eda7e4b290fed.tar.gz rails-9d5699a05ca625d531988d563d2eda7e4b290fed.tar.bz2 rails-9d5699a05ca625d531988d563d2eda7e4b290fed.zip |
Merge pull request #7368 from jbarreneche/bug/render-locale-fallbacks
i18n locale fallback for localized views
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/lookup_context.rb | 8 | ||||
-rw-r--r-- | actionpack/test/controller/localized_templates_test.rb | 9 |
3 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 0682593666..c1d6dac792 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,10 @@ ## unreleased ## +* Include I18n locale fallbacks in view lookup. + Fixes GH#3512. + + *Juan Barreneche* + * Fix incorrectly appended square brackets to a multiple select box if an explicit name has been given and it already ends with "[]". diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 33b508e9b5..9f617a9a53 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -44,7 +44,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) { Mime::SET.symbols } 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 41ff2f3809..a5fc3f614a 100644 --- a/actionpack/test/controller/localized_templates_test.rb +++ b/actionpack/test/controller/localized_templates_test.rb @@ -19,4 +19,13 @@ class LocalizedTemplatesTest < ActionController::TestCase get :hello_world assert_equal "Hello World", @response.body 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
\ No newline at end of file |