我希望Rails能夠像使用表單標籤一樣自動轉換佔位符文本。我怎樣才能做到這一點?如何在Rails 4中轉換佔位符文本?
表單標籤都是這樣自動翻譯:
= f.text_field :first_name
此助手使用區域設置文件:
en:
active_model:
models:
user:
attributes:
first_name: Your name
,輸出這個HTML
<label for="first_name">Your name</label>
我怎樣才能使它如此佔位符被翻譯?我是否需要輸入完整的示波器:
= f.text_field :first_name,
placeholder: t('.first_name', scope: 'active_model.models.user.attributes.first_name')
是否有更簡單的方法?
它需要'accepts_nested_attributes_for:model'嵌套模式。 – hlcs 2017-11-08 06:46:32