I\'m using arrays in a locale file to be able to generate blocks of text in various output methods (ActionMailer templates, Prawn documents, HAML templates) that are locale-spec
I think such thing is not supported natively in i18n gem, but it's doable using some meta-programming magic.
In an initializer (say, config/initializers/i18n.rb
) add the following
I18n.backend.instance_eval do
def interpolate(locale, string, values = {})
if string.is_a?(::Array) && !values.empty?
string.map { |el| super(locale, el, values) }
else
super
end
end
end