aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-06-19 19:08:14 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-06-19 19:08:14 +0200
commitb09c6e7444cf05f986e601bcc22cf17ede7b63bd (patch)
tree84f3d8a1085b41d0db71c25eaea6d1a43e177071 /actionpack/lib/action_view
parent2fe4d350e98d7f825cf3d1f9233075a5a79e32a1 (diff)
downloadrails-b09c6e7444cf05f986e601bcc22cf17ede7b63bd.tar.gz
rails-b09c6e7444cf05f986e601bcc22cf17ede7b63bd.tar.bz2
rails-b09c6e7444cf05f986e601bcc22cf17ede7b63bd.zip
add a generic tranlate view helper
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/i18n_helper.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/i18n_helper.rb b/actionpack/lib/action_view/helpers/i18n_helper.rb
new file mode 100644
index 0000000000..1b1d1f301d
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/i18n_helper.rb
@@ -0,0 +1,19 @@
+module ActionView
+ module Helpers
+ module I18nHelper
+ def translate(*args)
+ # inserts the locale or current request locale to the argument list if no locale
+ # has been passed or the locale has been passed as part of the options hash
+ options = args.extract_options!
+ if args.size != 2
+ locale = options.delete :locale
+ locale ||= request.locale if respond_to? :request
+ args << locale if locale
+ end
+ args << options unless options.empty?
+ I18n.translate *args
+ end
+ alias :t :translate
+ end
+ end
+end \ No newline at end of file