Allow translate default option to accept an array similar to i18n.t. Fixes #29441
This commit is contained in:
parent
db7398f79f
commit
ff3c06f718
|
@ -13,7 +13,7 @@ module AbstractController
|
|||
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 @@ module AbstractController
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue