i18n
i18n copied to clipboard
Interpolation in I18n array
According to: http://stackoverflow.com/questions/21574900/interpolation-in-i18n-array/25484080#25484080 Say my locale file looks like this:
en:
my_array:
- "Line 1"
- "Line 2"
- "Line 3 has a %{variable}"
- "Line 4"
I want the output of I18n.t('my_array', :variable => 'variable named variable') to be as follows:
["Line 1", "Line 2", "Line 3 has a variable named variable", "Line 4"]
However, the output is:
["Line 1", "Line 2", "Line 3 has a %{variable}", "Line 4"]
I don't think supporting this would be a good thing.
If you want to break translation across multiple lines yaml
already allow that:
en:
my_text: |
line 1
line 2
line 3
and if you want to make e.g. paragraphs in html you could do
I18n.t('my_text').split("\n").each { |line| print "<p>#{line}</p>" }
or use something like simple_format
I am request too; case example CSV-header.
settle for
I18n::Backend::Simple.new.send(:interpolate, args...)
for the time being to me.
When converting json or key/values to yaml, integer keys will get converted to arrays.