Merge pull request #29451 from vipulnsward/29441-flatten-default

Allow translate default option to accept an array similar to i18n.t
This commit is contained in:
Rafael França 2017-06-14 16:55:34 -04:00 committed by GitHub
commit f340490b98
2 changed files with 2 additions and 1 deletions

View File

@ -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)

View File

@ -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