Permalink
Browse files

Fixed that default locale templates should be used if the current loc…

…ale template is missing [DHH]
  • Loading branch information...
1 parent 1e3dce0 commit 99d54599215c2a8cea7e57f609e8e578043d71b2 Carl Lerche committed Apr 9, 2010
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.0.0 [Edge] (pending)*
+* Fixed that default locale templates should be used if the current locale template is missing [DHH]
+
* Added all the new HTML5 form types as individual form tag methods (search, url, number, etc) #3646 [Stephen Celis]
* Changed the object used in routing constraints to be an instance of
View
4 actionpack/lib/action_view/lookup_context.rb
@@ -38,7 +38,7 @@ module Accessors #:nodoc:
end
register_detail(:formats) { Mime::SET.symbols }
- register_detail(:locale) { [I18n.locale] }
+ register_detail(:locale) { [I18n.locale, I18n.default_locale] }
class DetailsKey #:nodoc:
alias :eql? :equal?
@@ -160,7 +160,7 @@ def locale=(value)
config = I18n.config.respond_to?(:i18n_config) ? I18n.config.i18n_config : I18n.config
config.locale = value
end
- super(I18n.locale)
+ super(_locale_defaults)
end
# Update the details keys by merging the given hash into the current
View
22 actionpack/test/controller/localized_templates_test.rb
@@ -0,0 +1,22 @@
+require 'abstract_unit'
+
+class LocalizedController < ActionController::Base
+ def hello_world
+ end
+end
+
+class LocalizedTemplatesTest < ActionController::TestCase
+ tests LocalizedController
+
+ def test_localized_template_is_used
+ I18n.locale = :de
+ get :hello_world
+ assert_equal "Gutten Tag", @response.body
+ end
+
+ def test_default_locale_template_is_used_when_locale_is_missing
+ I18n.locale = :dk
+ get :hello_world
+ assert_equal "Hello World", @response.body
+ end
+end
View
1 actionpack/test/fixtures/localized/hello_world.de.html
@@ -0,0 +1 @@
+Gutten Tag
@jonasschneider
jonasschneider Apr 9, 2010

Hey, it's "Guten Tag"!

@jonasschneider
jonasschneider Apr 9, 2010
From: Jonas Schneider <mail@jonasschneider.com>
Date: Fri, 9 Apr 2010 13:52:36 +0200
Subject: [PATCH] Fixed spelling error of the decade

---
 .../test/controller/localized_templates_test.rb    |    2 +-
 .../test/fixtures/localized/hello_world.de.html    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/actionpack/test/controller/localized_templates_test.rb b/actionpack/test/controller/localized_templates_test.rb
index 41ff2f3..af5a1ab 100644
--- a/actionpack/test/controller/localized_templates_test.rb
+++ b/actionpack/test/controller/localized_templates_test.rb
@@ -11,7 +11,7 @@ class LocalizedTemplatesTest < ActionController::TestCase
   def test_localized_template_is_used
     I18n.locale = :de
     get :hello_world
-    assert_equal "Gutten Tag", @response.body
+    assert_equal "Guten Tag", @response.body
   end

   def test_default_locale_template_is_used_when_locale_is_missing
diff --git a/actionpack/test/fixtures/localized/hello_world.de.html b/actionpack/test/fixtures/localized/hello_world.de.html
index 4727d7a..a8fc612 100644
--- a/actionpack/test/fixtures/localized/hello_world.de.html
+++ b/actionpack/test/fixtures/localized/hello_world.de.html
@@ -1 +1 @@
-Gutten Tag
\ No newline at end of file
+Guten Tag
\ No newline at end of file
--
1.5.6.5

applies on master.

View
1 actionpack/test/fixtures/localized/hello_world.en.html
@@ -0,0 +1 @@
+Hello World

1 comment on commit 99d5459

@jonasschneider
From: Jonas Schneider <mail@jonasschneider.com>
Date: Fri, 9 Apr 2010 13:52:36 +0200
Subject: [PATCH] Fixed spelling error of the decade

---
 .../test/controller/localized_templates_test.rb    |    2 +-
 .../test/fixtures/localized/hello_world.de.html    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/actionpack/test/controller/localized_templates_test.rb b/actionpack/test/controller/localized_templates_test.rb
index 41ff2f3..af5a1ab 100644
--- a/actionpack/test/controller/localized_templates_test.rb
+++ b/actionpack/test/controller/localized_templates_test.rb
@@ -11,7 +11,7 @@ class LocalizedTemplatesTest < ActionController::TestCase
   def test_localized_template_is_used
     I18n.locale = :de
     get :hello_world
-    assert_equal "Gutten Tag", @response.body
+    assert_equal "Guten Tag", @response.body
   end

   def test_default_locale_template_is_used_when_locale_is_missing
diff --git a/actionpack/test/fixtures/localized/hello_world.de.html b/actionpack/test/fixtures/localized/hello_world.de.html
index 4727d7a..a8fc612 100644
--- a/actionpack/test/fixtures/localized/hello_world.de.html
+++ b/actionpack/test/fixtures/localized/hello_world.de.html
@@ -1 +1 @@
-Gutten Tag
\ No newline at end of file
+Guten Tag
\ No newline at end of file
--
1.5.6.5

applies on master.

Please sign in to comment.