如何在表单标签助手中传递i18n插值变量?

cai*_*nne 10 ruby-on-rails internationalization ruby-on-rails-3

假设有一个en.yml

#en.yml
en:
  activerecord:
    books:
       price: "Price in %{currency}"
Run Code Online (Sandbox Code Playgroud)

然后可以在视图中执行以下操作

<%= t :price, :scope => "activerecord.attributes.book", :currency => "USD"%>
Run Code Online (Sandbox Code Playgroud)

它将打印"以美元计价".

但是,当这种翻译在表格中时,我无法弄清楚如何传递货币

# views/books/edit.html
f.label :price
Run Code Online (Sandbox Code Playgroud)

可以理解地抛出一个I18n :: MissingInterpolationArgument,但我无法弄清楚传递缺失参数的语法是什么

# views/books/edit.html
f.label :price, :currency => "USD"
Run Code Online (Sandbox Code Playgroud)

不起作用.

Cyg*_*sx1 11

我会尝试:

<%= f.label I18n.t(:price, :scope => "activerecord.attribute.book", :currency => "USD") %>
Run Code Online (Sandbox Code Playgroud)