Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Use i18n in action flash messages when generating resource (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoseriani authored and markbates committed Nov 4, 2018
1 parent d223ffd commit c3a83f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions generators/resource/templates/actions/resource-use_model.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}))
Expand Down Expand Up @@ -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}}))
Expand All @@ -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}}))
Expand Down

0 comments on commit c3a83f5

Please sign in to comment.