From 0aca0666a304983d145efb764c39a6952af7664a Mon Sep 17 00:00:00 2001 From: lulalala Date: Thu, 9 Nov 2017 23:00:50 +0800 Subject: [PATCH] Document about lambda return value also being interpolated --- lib/i18n.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/i18n.rb b/lib/i18n.rb index d79b661e..c3d97367 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -144,6 +144,10 @@ def reload! # # Then 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