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

generate app.go to have translations available in actions #370

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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