Skip to content

Commit

Permalink
Add comments exaplining new array behaviour for #interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartuz authored and stereobooster committed Nov 9, 2017
1 parent ae859dd commit 23069aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/i18n/backend/base.rb
Expand Up @@ -147,10 +147,17 @@ def pluralize(locale, entry, count)
entry[key]
end

# Interpolates values into a given string.
# Interpolates values into a given subject.
#
# interpolate "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X'
# if the given subject is a string then:
# method interpolates "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X'
# # => "file test.txt opened by %{user}"
#
# if the given subject is an array then:
# each element of the array is recursively interpolated (until it finds a string)
# method interpolates ["yes, %{user}", ["maybe no, %{user}, "no, %{user}"]], :user => "bartuz"
# # => "["yes, bartuz",["maybe no, bartuz", "no, bartuz"]]"


def interpolate(locale, subject, values = {})
return subject if values.empty?
Expand Down

0 comments on commit 23069aa

Please sign in to comment.