Skip to content

Commit

Permalink
Add comment on kwargs to avoid new people open issues like #500
Browse files Browse the repository at this point in the history
  • Loading branch information
alchimere committed Jan 4, 2020
1 parent 06aa9ac commit 0d02076
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ 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*
#
# This method uses keyword arguments.
# There is a breaking change in ruby that 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 0d02076

Please sign in to comment.