diff --git a/internal/components/translate/context.go b/internal/components/translate/context.go index d1f8e78..8a3ab5b 100644 --- a/internal/components/translate/context.go +++ b/internal/components/translate/context.go @@ -53,13 +53,21 @@ func Path(ctx context.Context, pp ...string) string { } func PathForLang(ctx context.Context, lang string, pp ...string) string { + slog.Debug("computing path for lang", "pp", pp, "lang", lang) s, ok := ctx.Value(serviceKey).(*Service) if !ok { slog.Error("could not extract translation service from context for translating path", "ctx", ctx, "path", pp) return path.Join(pp...) } + // remove leading "" + for len(pp) > 0 && pp[0] == "" { + pp = pp[1:] + } + if len(pp) > 0 { + + slog.Debug("computing path for lang", "pp", pp, "lang", lang, "pp[0]", pp[0], "translations", s.translations) if _, ok := s.translations[pp[0]]; ok { pp = pp[1:] } diff --git a/web/layouts/base.templ b/web/layouts/base.templ index e637e1e..13fb5a7 100644 --- a/web/layouts/base.templ +++ b/web/layouts/base.templ @@ -7,7 +7,7 @@ import ( "strings" ) -templ Head(cfg config.Cfg, title string) { +templ head(cfg config.Cfg, title string) {
@@ -29,29 +29,42 @@ templ Head(cfg config.Cfg, title string) { templ Base(cfg config.Cfg, title string) { - @Head(cfg, title) - -