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

Commit

Permalink
generate app.go to have translations available in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Apr 10, 2017
1 parent 4811f71 commit b3bbf75
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions generators/newapp/templates/actions/app.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
// application is being run. Default is "development".
var ENV = envy.Get("GO_ENV", "development")
var app *buffalo.App
var T *i18n.Translator

// App is where all routes and middleware for buffalo
// should be defined. This is the nerve center of your
Expand All @@ -37,12 +38,13 @@ func App() *buffalo.App {
app.Use(middleware.PopTransaction(models.DB))
{{ end }}

// Setup and use translations:
t, err := i18n.New(packr.NewBox("../locales"), "en-US")
if err != nil {
log.Fatal(err)
}
app.Use(t.Middleware())
// Setup and use translations:
var err error
T, err = i18n.New(packr.NewBox("../locales"), "en-US")
if err != nil {
log.Fatal(err)
}
app.Use(T.Middleware())

app.GET("/", HomeHandler)

Expand Down

0 comments on commit b3bbf75

Please sign in to comment.