diff --git a/views/categories.go b/views/categories.go index 73b1c9a..54cf349 100644 --- a/views/categories.go +++ b/views/categories.go @@ -13,6 +13,13 @@ import ( //go:embed categories.html var fs embed.FS +const categoriesRu = ` +{{define "empty cat"}}Эта категория пуста.{{end}} +{{define "add hypha"}}Добавить в категорию{{end}} +{{define "cat"}}Категория{{end}} +{{define "hypha name"}}Имя гифы{{end}} +` + var ( categoryT *template.Template ) @@ -44,7 +51,11 @@ func categoryCardHTML(hyphaName string) string { func CategoryPageHTML(meta Meta, catName string) { var buf strings.Builder - err := categoryT.ExecuteTemplate(&buf, "category page", struct { + var t, _ = categoryT.Clone() + if meta.Lc.Locale == "ru" { + _, _ = t.Parse(categoriesRu) + } + err := t.ExecuteTemplate(&buf, "category page", struct { CatName string Hyphae []string }{ diff --git a/views/categories.html b/views/categories.html index 1614d76..6eac0fe 100644 --- a/views/categories.html +++ b/views/categories.html @@ -29,11 +29,9 @@ {{define "category page"}} {{$catName := .CatName}}
-

Category {{$catName}}

- {{if len .Hyphae}} -

This page lists all hyphae in the category.

- {{else}} -

This category has no hyphae.

+

{{block "cat" .}}Category{{end}} {{beautifulName $catName}}

+ {{if len .Hyphae | not}} +

{{block "empty cat" .}}This category is empty{{end}}

{{end}}