]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/gopher.go
Templates translation
[sgblog.git] / cmd / sgblog / gopher.go
index f6bc3b4cc7a40aaad0532985653b4c39c077c4d3..2c8578fa6d9aaffa8cf0229d73e1f9a1a119713f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine
-Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2022 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
@@ -33,6 +33,7 @@ import (
        "github.com/go-git/go-git/v5"
        "github.com/go-git/go-git/v5/plumbing"
        "github.com/go-git/go-git/v5/plumbing/object"
+       "github.com/vorlif/spreak"
        "go.stargrave.org/sgblog"
 )
 
@@ -62,6 +63,7 @@ func serveGopher(cfgPath string) {
        if cfg.GopherDomain == "" {
                log.Fatalln("GopherDomain is not configured")
        }
+       initLocalizer(cfg.Lang)
 
        headHash, err := initRepo(cfg)
        if err != nil {
@@ -96,6 +98,7 @@ Redirecting to <a href="%s">%s</a>...
                        log.Fatalln(err)
                }
                err = TmplGopherEntry.Execute(os.Stdout, struct {
+                       T            *spreak.Localizer
                        Commit       *object.Commit
                        When         string
                        Cfg          *Cfg
@@ -105,6 +108,7 @@ Redirecting to <a href="%s">%s</a>...
                        Version      string
                        TitleEscaped string
                }{
+                       T:        localizer,
                        Commit:   commit,
                        When:     commit.Author.When.Format(sgblog.WhenFmt),
                        Cfg:      cfg,
@@ -183,6 +187,7 @@ Redirecting to <a href="%s">%s</a>...
                        offsetPrev = 0
                }
                err = TmplGopherMenu.Execute(os.Stdout, struct {
+                       T          *spreak.Localizer
                        Cfg        *Cfg
                        Topic      string
                        Offset     int
@@ -193,6 +198,7 @@ Redirecting to <a href="%s">%s</a>...
                        Topics     []string
                        Version    string
                }{
+                       T:          localizer,
                        Cfg:        cfg,
                        Topic:      topic,
                        Offset:     offset,