From 5d4a77d324fa30c616d0e05144edc57f10cfb9b5 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 14 Jun 2019 13:25:16 +0200 Subject: Fix TranslationHelper#translate handling of Hash defaults It is sometimes expected of the `translate` methods to return a Hash, for instance it's the case of the `number.format` key. As such users might need to specify a Hash default, e.g. `translate(:'some.format', default: { separator: '.', delimiter: ',' })`. This works as expected with the `I18n.translate` methods, however `TranslationHelper#translate` apply `Array()` on the default value. As a result the default value end up as `[:separator, '.', :delimiter, ',']`. --- actionview/lib/action_view/helpers/translation_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index d5b0a9263f..baa337c62f 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -60,7 +60,7 @@ module ActionView def translate(key, options = {}) options = options.dup if options.has_key?(:default) - remaining_defaults = Array(options.delete(:default)).compact + remaining_defaults = Array.wrap(options.delete(:default)).compact options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol) end -- cgit v1.2.3