aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorLuca Guidi <guidi.luca@gmail.com>2008-07-08 12:37:49 +0200
committerLuca Guidi <guidi.luca@gmail.com>2008-07-08 12:37:49 +0200
commitcf5d6ab9a849d19ac683180cc7b603ca94b13ed7 (patch)
tree2f8f679e37c1d6725040b311af2768dfda34b228 /actionpack
parent2949918b4cea26435d1f0a076fe884c8113b40fa (diff)
downloadrails-cf5d6ab9a849d19ac683180cc7b603ca94b13ed7.tar.gz
rails-cf5d6ab9a849d19ac683180cc7b603ca94b13ed7.tar.bz2
rails-cf5d6ab9a849d19ac683180cc7b603ca94b13ed7.zip
Added localize helper method
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb4
-rw-r--r--actionpack/test/template/translation_helper_test.rb6
2 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index c13c2dfc04..e1010ccf5f 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -11,6 +11,10 @@ module ActionView
keys = I18n.send :normalize_translation_keys, e.locale, e.key, e.options[:scope]
content_tag('span', keys.join(', '), :class => 'translation_missing')
end
+
+ def localize(*args)
+ I18n.l *args
+ end
end
end
end \ No newline at end of file
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb
index e97bcdb731..2263d48a65 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionpack/test/template/translation_helper_test.rb
@@ -39,4 +39,10 @@ class TranslationHelperTest < Test::Unit::TestCase
# error_messages_for(:object => @object, :locale => 'en-US')
# end
end
+
+ def test_delegates_localize_to_i18n
+ @time = Time.utc(2008, 7, 8, 12, 18, 38)
+ assert_equal "Tue, 08 Jul 2008 12:18:38 +0100", localize(@time)
+ assert_equal "08 Jul 12:18", localize(@time, :format => :short)
+ end
end \ No newline at end of file