diff --git a/go.mod b/go.mod index 16ccdc3..09d2cd5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.grassecon.net/urdt/ussd go 1.23.0 require ( - git.defalsify.org/vise.git v0.2.3-0.20241231085136-8582c7e157d9 + git.defalsify.org/vise.git v0.2.3-0.20250102175429-e5b5bc34a2be github.com/alecthomas/assert/v2 v2.2.2 github.com/gofrs/uuid v4.4.0+incompatible github.com/grassrootseconomics/eth-custodial v1.3.0-beta diff --git a/go.sum b/go.sum index 9086cd8..29b3893 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.defalsify.org/vise.git v0.2.3-0.20241231085136-8582c7e157d9 h1:O3m+NgWDWtJm8OculT99c4bDMAO4xLe2c8hpCKpsd9g= -git.defalsify.org/vise.git v0.2.3-0.20241231085136-8582c7e157d9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck= +git.defalsify.org/vise.git v0.2.3-0.20250102175429-e5b5bc34a2be h1:bh+VQanntFrMjQA/ZPRv5Wlist4e743EbiBvK1l9Qac= +git.defalsify.org/vise.git v0.2.3-0.20250102175429-e5b5bc34a2be/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g= diff --git a/internal/storage/storageservice.go b/internal/storage/storageservice.go index e420dee..451358e 100644 --- a/internal/storage/storageservice.go +++ b/internal/storage/storageservice.go @@ -59,14 +59,20 @@ func NewMenuStorageService(dbDir string, resourceDir string) *MenuStorageService } } +// WithGettext triggers use of gettext for translation of templates and menus. +// +// The first language in `lns` will be used as default language, to resolve node keys to +// language strings. +// +// If `lns` is an empty array, gettext will not be used. func (ms *MenuStorageService) WithGettext(path string, lns []lang.Language) *MenuStorageService { - ln := lang.Language{ - Code: "xxx", - Name: "Translation key", + if len(lns) == 0 { + logg.Warnf("Gettext requested but no languages supplied") + return ms } - rs := resource.NewPoResource(ln, path) + rs := resource.NewPoResource(lns[0], path) - for _, ln = range(lns) { + for _, ln := range(lns) { rs = rs.WithLanguage(ln) } @@ -138,6 +144,7 @@ func (ms *MenuStorageService) GetResource(ctx context.Context) (resource.Resourc } rfs := resource.NewDbResource(ms.resourceStore) if ms.poResource != nil { + logg.InfoCtxf(ctx, "using poresource for menu and template") rfs.WithMenuGetter(ms.poResource.GetMenu) rfs.WithTemplateGetter(ms.poResource.GetTemplate) }