mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #19649 from aprescott/allow-array-defaults
Allow an array to be a default translation value.
This commit is contained in:
commit
07875e2aa6
3 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
* `translate` allows `default: [[]]` again for a default value of `[]`.
|
||||
|
||||
Fixes #19640.
|
||||
|
||||
*Adam Prescott*
|
||||
|
||||
* `translate` should accept nils as members of the `:default`
|
||||
parameter without raising a translation missing error. Fixes a
|
||||
regression introduced 362557e.
|
||||
|
|
|
@ -41,7 +41,7 @@ module ActionView
|
|||
remaining_defaults = Array(options.delete(:default)).compact
|
||||
|
||||
if has_default && !remaining_defaults.first.kind_of?(Symbol)
|
||||
options[:default] = remaining_defaults.shift
|
||||
options[:default] = remaining_defaults
|
||||
end
|
||||
|
||||
# If the user has explicitly decided to NOT raise errors, pass that option to I18n.
|
||||
|
|
|
@ -195,6 +195,11 @@ class TranslationHelperTest < ActiveSupport::TestCase
|
|||
assert_equal 'A Generic String', translation
|
||||
end
|
||||
|
||||
def test_translate_with_array_of_array_default
|
||||
translation = translate(:'translations.missing', default: [[]])
|
||||
assert_equal [], translation
|
||||
end
|
||||
|
||||
def test_translate_does_not_change_options
|
||||
options = {}
|
||||
translate(:'translations.missing', options)
|
||||
|
|
Loading…
Reference in a new issue