ruby on rails - Translation for nested_attributes in polymorphic relationship -
i'm trying translate label of nested form attribute of polymorphic model. i'm using rails 4.
object relationship:
class question < activerecord::base has_many :attachments, as: :attachable, dependent: :destroy accepts_nested_attributes_for :attachments end class attachment < activerecord::base belongs_to :attachable, polymorphic: true end
my form:
= form_for @question |f| .form-group =f.text_area :body = fields_for :attachments |a| .form-group = a.label :file = a.file_field :file = f.submit
my ru.yml:
activerecord: attributes: question: attachment: file: Файл attachments: file: Файл attachment: file: Файл
doesn't work. should locale structure?
according to: http://api.rubyonrails.org/classes/actionview/helpers/formhelper.html#method-i-label
you should try with:
helpers: label: yourmodelname: yourmodelattr: "write entire text here"
this guessing i18n.locale
set :ru
hope helps you.
quoting documentation:
localization can based purely on translation of attribute-name (if using activerecord):
activerecord: attributes: post: cost: "total cost"
output:
f.label(:post, :cost) # => <label for="post_cost">total cost</label>
Comments
Post a Comment