If a project:
and I am using simple_form like so (simplified):
simple_form_for @project do |f|
f.input :project_name
f.simple_fields_for :tasks do |j|
j.input :task_name
end
f.submit
end
How would I internationalize the label for :task_name
? I have tried quite a few combinations in my simple_form.it.yml
file, such as:
it:
simple_form:
labels:
project:
project_name: 'Nome progetto'
task:
task_name: 'Nome compito'
Haven't been able to find examples in the docs. Google points out a couple of apparently relevant closed issues:
https://github.com/plataformatec/simple_form/issues/48
https://github.com/plataformatec/simple_form/issues/194
But so far I am at loss...
THANKS! Giuseppe
As far as your form accepts many tasks you should pluralize task
. It works in simple_form:
it:
simple_form:
labels:
project:
project_name: 'Nome progetto'
tasks:
task_name: 'Nome compito'
Use the default Rails i18n.
it:
activerecord:
attributes:
task:
task_name: 'Nome compito'
SimpleForm should fall back to it.simple_form.labels.task.task_name
but it don't.
You can simulate it with some YAML 'hack'.
it:
simple_form:
labels:
task: &task_labels
task_name: 'Nome compito'
project:
project_name: 'Nome progetto'
tasks:
<<: *task_labels
You can even customize the labels of project's tasks, after the <<: *task_labels
line.
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