import (
"crypto/sha1"
+ "embed"
"encoding/json"
"flag"
"fmt"
+ "io/fs"
"log"
"os"
"regexp"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/hjson/hjson-go"
+ "github.com/vorlif/spreak"
+ "golang.org/x/text/language"
)
const (
commentsTree *object.Tree
topicsRef *plumbing.Reference
topicsTree *object.Tree
+
+ localizer *spreak.Localizer
+
+ //go:embed locale/*
+ locales embed.FS
)
type Cfg struct {
GitPath string
Branch string
Title string
+ Lang string
URLPrefix string
return cfg, nil
}
+func initLocalizer(lang string) {
+ fsys, _ := fs.Sub(locales, "locale")
+ bundle, err := spreak.NewBundle(
+ spreak.WithSourceLanguage(language.English),
+ spreak.WithDomainFs(spreak.NoDomain, fsys),
+ spreak.WithLanguage(language.Russian),
+ )
+ if err != nil {
+ log.Fatalln(err)
+ }
+ if lang == "" {
+ lang = language.English.String()
+ }
+ localizer = spreak.NewLocalizer(bundle, language.MustParse(lang))
+}
+
func main() {
gopherCfgPath := flag.String("gopher", "", "Path to gopher-related configuration file")
geminiCfgPath := flag.String("gemini", "", "Path to gemini-related configuration file")