diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-12 15:39:17 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-12 15:39:17 -0200 |
commit | 76f6524538a50b4e3ede3d1ae58fcfbac3e77a91 (patch) | |
tree | aa5a2db6a29840b66c691f5ecddaa7c2203e76b7 /actionpack/lib/abstract_controller | |
parent | 68ce508e180eaed9539d2bea102861f9a56f50e6 (diff) | |
parent | fde7344542a76e7f1f95a2265ac5480a1ef9aeed (diff) | |
download | rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.tar.gz rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.tar.bz2 rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.zip |
Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r-- | actionpack/lib/abstract_controller/translation.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/lib/abstract_controller/translation.rb b/actionpack/lib/abstract_controller/translation.rb index 02028d8e05..56b8ce895e 100644 --- a/actionpack/lib/abstract_controller/translation.rb +++ b/actionpack/lib/abstract_controller/translation.rb @@ -8,14 +8,15 @@ module AbstractController # <tt>I18n.translate("people.index.foo")</tt>. This makes it less repetitive # to translate many keys within the same controller / action and gives you a # simple framework for scoping them consistently. - def translate(*args) - key = args.first - if key.is_a?(String) && (key[0] == '.') - key = "#{ controller_path.tr('/', '.') }.#{ action_name }#{ key }" - args[0] = key + def translate(key, options = {}) + if key.to_s.first == '.' + path = controller_path.tr('/', '.') + defaults = [:"#{path}#{key}"] + defaults << options[:default] if options[:default] + options[:default] = defaults + key = "#{path}.#{action_name}#{key}" end - - I18n.translate(*args) + I18n.translate(key, options) end alias :t :translate |