Skip to content

Commit

Permalink
Add comment on kwargs to avoid new people open issues like ruby-i18n#500
Browse files Browse the repository at this point in the history
  • Loading branch information
alchimere committed Nov 27, 2019
1 parent 06aa9ac commit ecc3781
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ def eager_load!
# from the argument values passed to #translate. Therefore your lambdas should
# always return the same translations/values per unique combination of argument
# values.
#
# *Ruby 2.7+ keyword arguments warning*
#
# The following code produces warning with ruby 2.7 and won't work as expected with ruby 3.0
# The "hash" parameter must be passed as keyword argument.
#
# Good:
# I18n.t(:salutation, :gender => 'w', :name => 'Smith')
# I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
# I18n.t(:salutation, **any_hash)
#
# Bad:
# I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
# I18n.t(:salutation, any_hash)
#
def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
locale ||= config.locale
raise Disabled.new('t') if locale == false
Expand Down

0 comments on commit ecc3781

Please sign in to comment.