Reputation: 8372
Suppose one has the following en.yml
#en.yml
en:
activerecord:
books:
price: "Price in %{currency}"
Then one can do the following in a view
<%= t :price, :scope => "activerecord.attributes.book", :currency => "USD"%>
and it will print "Price in USD".
But I can't figure out how to pass the currency when this translation is in a form
# views/books/edit.html
f.label :price
understandably throws an I18n::MissingInterpolationArgument, but I can't figure out what the syntax might be to pass the missing argument
# views/books/edit.html
f.label :price, :currency => "USD"
does not work.
Upvotes: 10
Views: 7825
Reputation: 5409
I would try:
<%= f.label I18n.t(:price, :scope => "activerecord.attribute.book", :currency => "USD") %>
Upvotes: 11