localise chrome, smooth prose, in English and Bengali

The engine now owns the words it puts on a page that the author did not write
(ADR-0034). `internal/render/chrome.go` holds the phrase table, Gregorian month
names and decimal digits per language, keyed phrase-then-language so both forms
sit side by side and a half-translated row is visible while reading. Templates
reach it through `t`, `num` and `day`, registered before parsing so a site
override's blocks may call them too.

The reference theme stops hardcoding English: "Newer", "Page 2 of 2" and every
date now come from the table, while `datetime` attributes stay ASCII because a
parser reads them.

Authored text gets goldmark's typographer and nothing else — quotes, dashes and
ellipses smoothed, code spans untouched because it works on the parsed tree. It
is a parser option rather than a function over a page, so the transforms counter
does not move; state.md now says why, so the next reader does not miscount.

Deliberately absent: relative dates, which need a validity window that only the
cache entry will have, and body widow prevention, which cannot be done safely by
a pass over rendered HTML.
This commit is contained in:
2026-08-01 02:23:35 +06:00
parent 206974650d
commit c244855ebc
8 changed files with 283 additions and 17 deletions
+6 -6
View File
@@ -6,7 +6,7 @@
<ul class="listing">
{{- range .Items}}
<li><a href="{{.URL}}">{{if .Title}}{{.Title}}{{else}}{{.Key}}{{end}}</a>
{{- if not .Date.IsZero}} <time datetime="{{.Date.Format "2006-01-02"}}">{{.Date.Format "2 January 2006"}}</time>{{end}}</li>
{{- if not .Date.IsZero}} <time datetime="{{.Date.Format "2006-01-02"}}">{{day $.Lang .Date}}</time>{{end}}</li>
{{- end}}
</ul>
{{- end}}
@@ -14,17 +14,17 @@
<ul class="listing">
{{- range .Items}}
<li><a href="{{.URL}}">{{if .Title}}{{.Title}}{{else}}{{.Key}}{{end}}</a>
{{- if not .Date.IsZero}} <time datetime="{{.Date.Format "2006-01-02"}}">{{.Date.Format "2 January 2006"}}</time>{{end}}</li>
{{- if not .Date.IsZero}} <time datetime="{{.Date.Format "2006-01-02"}}">{{day $.Lang .Date}}</time>{{end}}</li>
{{- end}}
</ul>
{{- else}}
<p>Nothing here yet.</p>
<p>{{t .Lang "empty"}}</p>
{{- end}}
{{- if or .PrevURL .NextURL}}
<nav class="pagination">
{{- if .PrevURL}}<a rel="prev" href="{{.PrevURL}}">Newer</a>{{end}}
<span>Page {{.Page}} of {{.Pages}}</span>
{{- if .NextURL}}<a rel="next" href="{{.NextURL}}">Older</a>{{end}}
{{- if .PrevURL}}<a rel="prev" href="{{.PrevURL}}">{{t .Lang "newer"}}</a>{{end}}
<span>{{t .Lang "page-of" (num .Lang .Page) (num .Lang .Pages)}}</span>
{{- if .NextURL}}<a rel="next" href="{{.NextURL}}">{{t .Lang "older"}}</a>{{end}}
</nav>
{{- end}}
{{- end}}