File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change
1
+ * ` ActionView::Helpers::TranslationHelper#translate ` returns nil when
2
+ passed ` default: nil ` without a translation matching ` I18n#translate ` .
3
+
4
+ * Stefan Wrobel*
5
+
1
6
* ` OptimizedFileSystemResolver ` prefers template details in order of locale,
2
7
formats, variants, handlers.
3
8
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ module TranslationHelper
58
58
# when you call translate in a template and translators know which keys
59
59
# they can provide HTML values for.
60
60
def translate ( key , **options )
61
- if options . has_key? ( :default )
61
+ unless options [ :default ] . nil?
62
62
remaining_defaults = Array . wrap ( options . delete ( :default ) ) . compact
63
63
options [ :default ] = remaining_defaults unless remaining_defaults . first . kind_of? ( Symbol )
64
64
end
Original file line number Diff line number Diff line change @@ -242,6 +242,16 @@ def test_translate_with_array_of_array_default
242
242
assert_equal [ ] , translation
243
243
end
244
244
245
+ def test_translate_with_false_default
246
+ translation = translate ( :'translations.missing' , default : false )
247
+ assert_equal false , translation
248
+ end
249
+
250
+ def test_translate_with_nil_default
251
+ translation = translate ( :'translations.missing' , default : nil )
252
+ assert_nil translation
253
+ end
254
+
245
255
def test_translate_does_not_change_options
246
256
options = { }
247
257
if RUBY_VERSION >= "2.7"
You can’t perform that action at this time.
0 commit comments