Allow translate default option to accept an array similar to i18n.t. Fixes #29441

This commit is contained in:
Vipul A M 2017-06-15 01:06:04 +05:30
parent db7398f79f
commit ff3c06f718
No known key found for this signature in database
GPG Key ID: 4C9362FE1F574587
2 changed files with 2 additions and 1 deletions

@ -13,7 +13,7 @@ def translate(key, options = {})
path = controller_path.tr("/", ".")
defaults = [:"#{path}#{key}"]
defaults << options[:default] if options[:default]
options[:default] = defaults
options[:default] = defaults.flatten
key = "#{path}.#{action_name}#{key}"
end
I18n.translate(key, options)

@ -62,6 +62,7 @@ def test_lazy_lookup_fallback
def test_default_translation
@controller.stub :action_name, :index do
assert_equal "bar", @controller.t("one.two")
assert_equal "baz", @controller.t(".twoz", default: ["baz", :twoz])
end
end