The portal in English and Turkish: a catalogue per language, a switcher at the foot of every page, landing.language, Turkish numbers and dates

Every template and handler message in internal/web goes through a JSON
catalogue under internal/web/locales/<code>/, with English as the fallback.
The language is the person's choice (a cookie set by /_lang/{code}), else
Accept-Language, else landing.language. Tests refuse a key some language
lacks, a translation with other arguments than English, and template text
left in English.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 00:12:53 +02:00
1 parent 30f7f3474a
commit 11231d8c2b
113 files changed
+8091 -1981

No files matched your search

+34 -17
View File
@@ -32,20 +32,29 @@ const minParams = 50e6
// exploreShown is how many rows the explorer lists.
const exploreShown = 25
var exploreViews = []struct{ key, label string }{
{viewTrending, "Trending"}, {viewNew, "New this month"}, {viewDownloads, "Most downloaded"},
{viewAdapters, "LoRA adapters"},
// The labels are catalogue keys: explore.view.<key>, explore.task.<key>.
var exploreViews = []string{viewTrending, viewNew, viewDownloads, viewAdapters}
var exploreTasks = []struct{ key, tag string }{
{"chat", "text-generation"}, {"embed", "feature-extraction"}, {"any", ""},
}
var exploreTasks = []struct{ key, label, tag string }{
{"chat", "Chat", "text-generation"}, {"embed", "Embeddings", "feature-extraction"}, {"any", "Any task", ""},
func init() {
for _, v := range exploreViews {
registerKeys("explore.view." + v)
}
for _, t := range exploreTasks {
registerKeys("explore.task." + t.key)
}
registerKeys("explore.size.any")
}
var exploreSizes = []struct {
key, label string
max int64
}{
{"3", "≤ 3B", 3e9}, {"9", "≤ 9B", 9e9}, {"35", "≤ 35B", 35e9}, {"any", "Any size", 0},
// "any" is named in words, explore.size.any; the others are figures.
{"3", "≤ 3B", 3e9}, {"9", "≤ 9B", 9e9}, {"35", "≤ 35B", 35e9}, {"any", "", 0},
}
// explorer is the registry half of the mirror page when no repository is
@@ -77,6 +86,8 @@ type exploreRow struct {
Verdict gguf.Verdict
Href template.URL
New bool
// Updated is how long ago the repository changed, in the page's language.
Updated string
}
// ParamsLabel is the parameter count as people say it: 7.6B, 494M.
@@ -100,8 +111,8 @@ func (r exploreRow) ContextLabel() string {
return fmt.Sprintf("%dk", r.GGUF.ContextLength/1024)
}
// Age is how long ago the repository last changed, coarsely.
func (r exploreRow) Age() string {
// age is how long ago the repository last changed, coarsely.
func (r exploreRow) age(l *Lang) string {
t := r.LastModified
if t.IsZero() {
t = r.CreatedAt
@@ -112,15 +123,15 @@ func (r exploreRow) Age() string {
d := time.Since(t)
switch {
case d < time.Hour:
return "just now"
return l.T("explore.age.now")
case d < 48*time.Hour:
return fmt.Sprintf("%dh", int(d.Hours()))
return l.T("explore.age.h", int(d.Hours()))
case d < 14*24*time.Hour:
return fmt.Sprintf("%dd", int(d.Hours()/24))
return l.T("explore.age.d", int(d.Hours()/24))
case d < 60*24*time.Hour:
return fmt.Sprintf("%dw", int(d.Hours()/24/7))
return l.T("explore.age.w", int(d.Hours()/24/7))
default:
return fmt.Sprintf("%dmo", int(d.Hours()/24/30))
return l.T("explore.age.mo", int(d.Hours()/24/30))
}
}
@@ -229,20 +240,25 @@ func (p *AccountPages) exploreList(r *http.Request, d *adminMirrorData) {
e.Of = repo.BaseModel[0]
}
}
l := langOf(r)
for _, v := range exploreViews {
e.Views = append(e.Views, exploreLink{v.label, e.href(d.Query, "view", v.key), v.key == e.View})
e.Views = append(e.Views, exploreLink{l.T("explore.view." + v), e.href(d.Query, "view", v), v == e.View})
}
for _, t := range exploreTasks {
e.Tasks = append(e.Tasks, exploreLink{t.label, e.href(d.Query, "task", t.key), t.key == e.Task})
e.Tasks = append(e.Tasks, exploreLink{l.T("explore.task." + t.key), e.href(d.Query, "task", t.key), t.key == e.Task})
}
for _, s := range exploreSizes {
e.Sizes = append(e.Sizes, exploreLink{s.label, e.href(d.Query, "size", s.key), s.key == e.Size})
label := s.label
if label == "" {
label = l.T("explore.size." + s.key)
}
e.Sizes = append(e.Sizes, exploreLink{label, e.href(d.Query, "size", s.key), s.key == e.Size})
}
d.Explore = &e
got, err := p.registry.Explore(r.Context(), e.hfQuery(d.Query))
if err != nil {
d.RegistryErr = err.Error()
d.RegistryErr = l.Err(err)
return
}
back := e.href(d.Query, "", "")
@@ -253,6 +269,7 @@ func (p *AccountPages) exploreList(r *http.Request, d *adminMirrorData) {
row := exploreRow{Model: m, Verdict: gguf.Verdict{Servable: true},
Href: back + template.URL("&repo="+url.QueryEscape(m.ID)),
New: !m.CreatedAt.IsZero() && time.Since(m.CreatedAt) < newWithin}
row.Updated = row.age(l)
if a := m.Architecture(); a != "" && p.llamaVersion != "" {
row.Verdict = gguf.LlamaCpp(p.llamaVersion, a)
}