Skip to content

Commit

Permalink
Document about lambda return value also being interpolated
Browse files Browse the repository at this point in the history
  • Loading branch information
lulalala committed Nov 9, 2017
1 parent 2923396 commit 0aca066
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/i18n.rb
Expand Up @@ -144,6 +144,10 @@ def reload!
#
# Then <tt>I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith".
#
# Note that the string returned by lambda will go through string interpolation too,
# so the following lambda would give the same result:
# lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" }
#
# It is recommended to use/implement lambdas in an "idempotent" way. E.g. when
# a cache layer is put in front of I18n.translate it will generate a cache key
# from the argument values passed to #translate. Therefor your lambdas should
Expand Down

0 comments on commit 0aca066

Please sign in to comment.