1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

updates from review, WIP

This commit is contained in:
Lee Brown
2019-08-22 17:33:47 -08:00
parent d3b97a6608
commit 998d1bf13e
15 changed files with 158 additions and 25 deletions

5
internal/README.md Normal file
View File

@ -0,0 +1,5 @@
# `/internal`
Private application and library code. This is the code you don't want others importing in their applications or libraries.
You can optionally add a bit of extra structure to your internal packages to separate your shared and non-shared internal code. It's not required, but it's nice to have visual clues showing the intended package use. Your actual application code can go in the /internal/app directory (e.g., /internal/app/myapp) and the code shared by those apps in the /internal/pkg directory (e.g., /internal/pkg/myprivlib).

View File

@ -373,8 +373,6 @@ func (r *TemplateRenderer) Render(ctx context.Context, w http.ResponseWriter, re
data["error"] = terr
}
data["trans"] = webcontext.ContextTranslator(ctx)
// Append request data map to render data last so any previous value can be overwritten.
if data != nil {
for k, v := range data {

View File

@ -4,6 +4,7 @@ import (
"context"
"log"
"os"
"path/filepath"
"reflect"
"strings"
@ -65,8 +66,24 @@ func init() {
// Provide one or more arguments for additional supported locales.
uniTrans = ut.New(en, en, fr, id, ja, nl, zh)
if _, err := os.Stat("templates/content/translations"); !os.IsNotExist(err) {
err := uniTrans.Import(ut.FormatJSON, "templates/content/translations")
// Try to load the Template directory from an environment variable for release images else it's local development.
var transDir string
if ev := os.Getenv("TRANSLATIONS_DIR"); ev != "" {
transDir = ev
} else {
if ev := os.Getenv("SHARED_TEMPLATE_DIR"); ev != "" {
transDir = ev
} else if ev := os.Getenv("TEMPLATE_DIR"); ev != "" {
transDir = ev
} else {
transDir = "./templates"
}
transDir = filepath.Join(transDir, "translations")
}
if _, err := os.Stat(transDir); !os.IsNotExist(err) {
err := uniTrans.Import(ut.FormatJSON, transDir)
if err != nil {
log.Fatal(err)
}