From c3a83f574d8bec28274019437bb7f14abee41f96 Mon Sep 17 00:00:00 2001 From: Ricardo Seriani Date: Sun, 4 Nov 2018 18:18:10 -0300 Subject: [PATCH] Use i18n in action flash messages when generating resource (#1429) --- .../templates/actions/resource-use_model.go.tmpl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/generators/resource/templates/actions/resource-use_model.go.tmpl b/generators/resource/templates/actions/resource-use_model.go.tmpl index 095384f68..de16ddeda 100644 --- a/generators/resource/templates/actions/resource-use_model.go.tmpl +++ b/generators/resource/templates/actions/resource-use_model.go.tmpl @@ -109,8 +109,10 @@ func (v {{.opts.Name.Resource}}Resource) Create(c buffalo.Context) error { return c.Render(422, r.Auto(c, {{.opts.Model.VarCaseSingular}})) } + {{ if .opts.App.AsWeb -}} // If there are no errors set a success message - c.Flash().Add("success", "{{.opts.Model.Model}} was created successfully") + c.Flash().Add("success", T.Translate(c, "{{.opts.Model.VarCaseSingular}}.created.success")) + {{ end -}} // and redirect to the {{.opts.Name.URL}} index page return c.Render(201, r.Auto(c, {{.opts.Model.VarCaseSingular}})) @@ -170,8 +172,10 @@ func (v {{.opts.Name.Resource}}Resource) Update(c buffalo.Context) error { return c.Render(422, r.Auto(c, {{.opts.Model.VarCaseSingular}})) } + {{ if .opts.App.AsWeb -}} // If there are no errors set a success message - c.Flash().Add("success", "{{.opts.Model.Model}} was updated successfully") + c.Flash().Add("success", T.Translate(c, "{{.opts.Model.VarCaseSingular}}.updated.success")) + {{ end -}} // and redirect to the {{.opts.Name.URL}} index page return c.Render(200, r.Auto(c, {{.opts.Model.VarCaseSingular}})) @@ -198,8 +202,10 @@ func (v {{.opts.Name.Resource}}Resource) Destroy(c buffalo.Context) error { return errors.WithStack(err) } + {{ if .opts.App.AsWeb -}} // If there are no errors set a flash message - c.Flash().Add("success", "{{.opts.Model.Model}} was destroyed successfully") + c.Flash().Add("success", T.Translate(c, "{{.opts.Model.VarCaseSingular}}.destroyed.success")) + {{ end -}} // Redirect to the {{.opts.Name.URL}} index page return c.Render(200, r.Auto(c, {{.opts.Model.VarCaseSingular}}))