假设有以下en.yml文件:
#en.yml
en:
activerecord:
books:
price: "Price in %{currency}"
然后在视图中可以这样做:
<%= t :price, :scope => "activerecord.attributes.book", :currency => "USD"%>
它将打印出"价格以美元计算"。
但是当这个翻译被放在一个表单中时,我无法确定如何传递货币信息。
# views/books/edit.html
f.label :price
可以理解为抛出了I18n :: MissingInterpolationArgument,但我无法确定传递缺失参数的语法是什么
# views/books/edit.html
f.label :price, :currency => "USD"
无法正常工作。