Last Updated: February 25, 2016
·
574
· flemon

i18n a list

thanks to Henrik Nyh's blog

en:
  steps: |
    do this
    do that
    do this again

the key is the bar character '|', and can't use double quotes "" in this case

<ul>
<% t('steps').each_line do |step| %>
  <li><%= step %></li>
<% end %>
</ul>

3 Responses
Add your response

IMHO better idea is to use YAML array:

en:
  steps:
    - do this
    - do that
    - do this again

and then you can use it as an normal array:

<ul>
  <%- t('steps').each do |step| -%>
    <li><%= step %></li>
  <%- end -%>
</ul>
over 1 year ago ·

@hauleth oh yes, i like your approach better

over 1 year ago ·

@hauleth how do you pass a %{variable} into one of this list item? i can't get this to work.

over 1 year ago ·