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.
I would try:
<%= f.label I18n.t(:price, :scope => "activerecord.attribute.book", :currency => "USD") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With