From a9fe44f73c0986d2127ff9275b479bbac77e7c47 Mon Sep 17 00:00:00 2001 From: Juan Manuel Ramallo Date: Tue, 7 Apr 2020 09:18:13 -0300 Subject: [PATCH] Updated simple form recipe (#32) - Fixed i18n section --- docs/recipes/simple_form.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/recipes/simple_form.md b/docs/recipes/simple_form.md index 4b5a954..de84a39 100644 --- a/docs/recipes/simple_form.md +++ b/docs/recipes/simple_form.md @@ -59,8 +59,24 @@ In order to make use of translations correctly, we should pass an `as` value to ... ``` -If you'd rather not modify your forms with this attribute, you can override the `model_name` method in your form object, -so that Simple Form is able to look for the correct translations. +So you now can write your translations as: + +```yaml +# app/config/locales/simple_form.en.yml + +en: + simple_form: + ... + + labels: + book: + name: Book Name + isbn: International Standard Book Number +``` + +When using the `f.submit` helper method from Simple Form, the method `model_name` will be used to display the +button's text. If this is not defined it will display: "Create Book Form". +You can use a translation directly in the view to avoid overriding this method. ```ruby # app/forms/book_form.rb