messages: custom content described in customcontent.go, message tests

customcontent.go constains a structure with all the custom content,
methods for getting display names, subjects, etc., and a list of
variables, conditionals, and placeholder values. Tests for constructX
methods included in email_test.go, and all jfa-go tests can be run with
make INTERNAL=off test.
This commit is contained in:
Harvey Tindall
2025-08-30 14:21:26 +01:00
parent 0b43ad4ed5
commit 60dbfa2d1e
27 changed files with 1646 additions and 1141 deletions

10
lang.go
View File

@@ -1,6 +1,10 @@
package main
import "github.com/hrfee/jfa-go/common"
import (
"fmt"
"github.com/hrfee/jfa-go/common"
)
type langMeta struct {
Name string `json:"name"`
@@ -166,7 +170,7 @@ func (ts *telegramLangs) getOptions() []common.Option {
}
type langSection map[string]string
type tmpl map[string]string
type tmpl = map[string]any
func templateString(text string, vals tmpl) string {
start, previousEnd := -1, -1
@@ -183,7 +187,7 @@ func templateString(text string, vals tmpl) string {
start = -1
continue
}
out += text[previousEnd+1:start] + val
out += text[previousEnd+1:start] + fmt.Sprint(val)
previousEnd = i
start = -1
}