Skip to content

Commit 7559fef

Browse files
committed
More examples documented
1 parent fe82be8 commit 7559fef

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/i18n.rb

+5
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,23 @@ def translate!(key, **options)
233233

234234
# Returns an array of interpolation keys for the given translation key
235235
#
236+
# *Examples*
237+
#
236238
# Suppose we have the following:
237239
# I18n.t 'example.zero' == 'Zero interpolations'
238240
# I18n.t 'example.one' == 'One interpolation %{foo}'
239241
# I18n.t 'example.two' == 'Two interpolations %{foo} %{bar}'
242+
# I18n.t 'example.three' == ['One %{foo}', 'Two %{bar}', 'Three %{baz}']
240243
# I18n.t 'example.one', locale: :other == 'One interpolation %{baz} %{bar}'
241244
#
242245
# Then we can expect the following results:
243246
# I18n.interpolation_keys('example.zero') #=> []
244247
# I18n.interpolation_keys('example.one') #=> ['foo']
245248
# I18n.interpolation_keys('example.two') #=> ['foo', 'bar']
249+
# I18n.interpolation_keys('example.three') #=> ['foo', 'bar', 'baz']
246250
# I18n.interpolation_keys('one', scope: 'example', locale: :other) #=> ['baz']
247251
# I18n.interpolation_keys('does-not-exist') #=> []
252+
# I18n.interpolation_keys('example') #=> []
248253
def interpolation_keys(key, **options)
249254
raise I18n::ArgumentError if !key.is_a?(String) || key.empty?
250255

0 commit comments

Comments
 (0)