From e14a4250efb828262347f5a4bbc4067cd71d885f Mon Sep 17 00:00:00 2001 From: grm Date: Mon, 14 Sep 2026 01:32:25 +0300 Subject: Add languages: English and Greek, chosen per blog on the Settings tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every blog and its dashboard were hard-wired to English. A blogger can now pick the language of their blog; it switches the whole dashboard and the blog's fixed text — post dates, archive months, the RSS link, the pager, the 404 page — while what the blogger wrote is left alone. The new internal/i18n package keys translations by the English string, so an untranslated key renders as English rather than blank, and TestGreekCatalogComplete scans the templates and handlers to fail when the Greek catalog misses a key or keeps a stale one. Templates are compiled once per language with t/tf/date/postdate/month closed over the language, so they need no data plumbing. The language lives in settings.language (blog migration 00002), not in the theme, so "Reset design" does not touch it. Public pages use the blog's language; management pages use the logged-in user's own blog's, so a superadmin editing someone else's blog keeps theirs; the login page follows Accept-Language. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/theme.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'internal/web/theme.go') diff --git a/internal/web/theme.go b/internal/web/theme.go index 1ecd832..2853667 100644 --- a/internal/web/theme.go +++ b/internal/web/theme.go @@ -8,7 +8,6 @@ import ( "strconv" "strings" "text/template" - "time" "github.com/google/uuid" ) @@ -43,7 +42,7 @@ type Theme struct { NavHover string `json:"nav_hover"` // "" = same as NavText ShowDates bool `json:"show_dates"` - DateFormat string `json:"date_format"` // long | short | iso + DateFormat string `json:"date_format"` // long | short | iso (rendered by i18n.FormatDate) FooterBg string `json:"footer_bg"` FooterColor string `json:"footer_color"` @@ -283,17 +282,6 @@ func (t Theme) JSON() json.RawMessage { return b } -// FormatDate renders post dates in the blogger's chosen style. -func (t Theme) FormatDate(at time.Time) string { - switch t.DateFormat { - case "short": - return at.Format("2 Jan 2006") - case "iso": - return at.Format("2006-01-02") - } - return at.Format("2 January 2006") -} - // ---- presets ---------------------------------------------------------------- // Preset is a named colour scheme; applying one touches only colours. -- cgit v1.2.3