summaryrefslogtreecommitdiff
path: root/internal/web/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/server.go')
-rw-r--r--internal/web/server.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/web/server.go b/internal/web/server.go
index 10401ed..3b7102c 100644
--- a/internal/web/server.go
+++ b/internal/web/server.go
@@ -19,6 +19,7 @@ import (
"time"
"github.com/lukaszkasprzak/lectio/internal/config"
+ "github.com/lukaszkasprzak/lectio/internal/i18n"
"github.com/lukaszkasprzak/lectio/internal/liturgy"
"github.com/lukaszkasprzak/lectio/internal/readings"
"github.com/lukaszkasprzak/lectio/internal/render"
@@ -183,6 +184,10 @@ type indexData struct {
Display string
Mono bool
Reading template.HTML
+ // L holds the localised control labels (lectionary/layout/theme/...),
+ // set from i18n.Get(cfg.UILanguage) -- index.html references its
+ // fields (e.g. {{.L.Lectionary}}) instead of hardcoded Polish text.
+ L i18n.UI
}
type versionOpt struct {
@@ -207,7 +212,7 @@ func indexHandler(cfg config.Config) http.HandlerFunc {
}
secs, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
- reading := renderOrError(secs, loadVersions, lectionary, display, err)
+ reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, err)
// Check the boxes for the versions actually rendered (loadVersions),
// not the raw request: traditional/offline substitute pl->wuj, so the
@@ -239,6 +244,7 @@ func indexHandler(cfg config.Config) http.HandlerFunc {
Display: display,
Mono: queryBool(r, "mono", cfg.WebMono),
Reading: reading,
+ L: i18n.Get(cfg.UILanguage),
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -255,7 +261,7 @@ func readingsHandler(cfg config.Config) http.HandlerFunc {
date, lectionary, all, versions, display := resolveQuery(cfg, r)
secs, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
- reading := renderOrError(secs, loadVersions, lectionary, display, err)
+ reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, err)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
io.WriteString(w, string(reading))
@@ -266,14 +272,14 @@ func readingsHandler(cfg config.Config) http.HandlerFunc {
// error) a small escaped error paragraph -- readings.Load errors are
// expected in normal operation (an unpublished date, no network while
// online, ...) so the pane should show them, not 500.
-func renderOrError(secs []liturgy.Section, versions []string, lectionary, display string, err error) template.HTML {
+func renderOrError(secs []liturgy.Section, versions []string, lectionary, display, lang string, err error) template.HTML {
if err != nil {
return template.HTML(`<p class="error">` + template.HTMLEscapeString(err.Error()) + `</p>`)
}
if len(secs) == 0 {
return template.HTML(`<p class="error">brak czytań na ten dzień</p>`)
}
- return RenderReadings(secs, versions, lectionary, display)
+ return RenderReadings(secs, versions, lectionary, display, lang)
}
// themeCSSHandler serves one theme's stylesheet: the requested name, or