diff options
Diffstat (limited to 'internal/web/layout.go')
| -rw-r--r-- | internal/web/layout.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/web/layout.go b/internal/web/layout.go index 521cb63..ad55e82 100644 --- a/internal/web/layout.go +++ b/internal/web/layout.go @@ -2,10 +2,10 @@ package web import ( "net/url" - "strconv" "strings" "time" + "github.com/gramanas/blogspace/internal/i18n" "github.com/gramanas/blogspace/internal/store" ) @@ -20,7 +20,7 @@ var moduleKinds = map[string][]string{ "footer": {"text", "rss", "sitemap", "html"}, } -// Friendly names for the dashboard. +// Friendly names for the dashboard (English; translate with t / s.tr at the point of use). var moduleNames = map[string]string{ "title": "Blog title & tagline", "logo": "Logo", @@ -60,28 +60,28 @@ func moduleHasSettings(kind string) bool { } // moduleSummary is the one-liner the Layout page shows next to a module's name. -func moduleSummary(m store.Module) string { +func moduleSummary(lang string, m store.Module) string { switch m.Kind { case "recent": - return strconv.Itoa(m.Count) + " posts" + headingNote(m) + return i18n.Tf(lang, "%d posts", m.Count) + headingNote(lang, m) case "html", "text": body := strings.Join(strings.Fields(m.Body), " ") if body == "" { - return "empty" + return i18n.T(lang, "empty") } if len(body) > 60 { body = body[:57] + "…" } return body } - return strings.TrimPrefix(headingNote(m), ", ") + return strings.TrimPrefix(headingNote(lang, m), ", ") } -func headingNote(m store.Module) string { +func headingNote(lang string, m store.Module) string { if m.Title == "" { return "" } - return ", heading “" + m.Title + "”" + return ", " + i18n.Tf(lang, "heading “%s”", m.Title) } // validLinkURL accepts what a menu link may point to: a web address, a mail @@ -174,7 +174,7 @@ func (l Layout) MaxRecent() int { // ---- archive --------------------------------------------------------------- type ArchiveMonth struct { - Name string // "September" + Month time.Month // named by the template in the blog's language Posts []store.PostRef } @@ -196,7 +196,7 @@ func groupArchive(posts []store.PostRef) []ArchiveYear { } yr := &years[len(years)-1] if len(yr.Months) == 0 || m != lastM { - yr.Months = append(yr.Months, ArchiveMonth{Name: time.Month(m).String()}) + yr.Months = append(yr.Months, ArchiveMonth{Month: time.Month(m)}) } mo := &yr.Months[len(yr.Months)-1] mo.Posts = append(mo.Posts, p) |
