mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-04 18:19:54 +00:00
Categories: Localized titles
This commit is contained in:
parent
9d971871eb
commit
0ab4bb5846
@ -1,4 +1,5 @@
|
||||
{{define "title"}}Category list{{end}}
|
||||
{{define "category list"}}Category list{{end}}
|
||||
{{define "title"}}{{template "category list"}}{{end}}
|
||||
{{define "body"}}
|
||||
<main class="main-width category-list">
|
||||
<h1>{{template "title"}}</h1>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{{define "title"}}Category {{.CatName | beautifulName}}{{end}}
|
||||
{{define "category x"}}Category {{. | beautifulName}}{{end}}
|
||||
{{define "title"}}{{template "category x" .CatName}}{{end}}
|
||||
{{define "body"}}
|
||||
{{$catName := .CatName}}
|
||||
<main class="main-width category">
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"text/template" // TODO: Fight
|
||||
)
|
||||
|
||||
const categoriesRu = `
|
||||
const ruTranslation = `
|
||||
{{define "empty cat"}}Эта категория пуста.{{end}}
|
||||
{{define "add hypha"}}Добавить в категорию{{end}}
|
||||
{{define "cat"}}Категория{{end}}
|
||||
@ -18,7 +18,7 @@ const categoriesRu = `
|
||||
{{define "placeholder"}}Имя категории...{{end}}
|
||||
{{define "remove from category title"}}Убрать гифу из этой категории{{end}}
|
||||
{{define "add to category title"}}Добавить гифу в эту категорию{{end}}
|
||||
{{define "category list heading"}}Список категорий{{end}}
|
||||
{{define "category list"}}Список категорий{{end}}
|
||||
{{define "no categories"}}В этой вики нет категорий.{{end}}
|
||||
{{define "category x"}}Категория {{. | beautifulName}}{{end}}
|
||||
`
|
||||
@ -26,31 +26,29 @@ const categoriesRu = `
|
||||
var (
|
||||
//go:embed *.html
|
||||
fs embed.FS
|
||||
m = template.Must
|
||||
baseEn, baseRu *template.Template
|
||||
viewListChain, viewPageChain, viewCardChain viewutil.Chain
|
||||
)
|
||||
|
||||
func prepareViews() {
|
||||
|
||||
baseEn = m(viewutil.BaseEn.Clone())
|
||||
baseRu = m(viewutil.BaseRu.Clone())
|
||||
var (
|
||||
m = template.Must
|
||||
copyEnWith = func(f string) *template.Template {
|
||||
return m(m(viewutil.BaseEn.Clone()).ParseFS(fs, f))
|
||||
}
|
||||
copyRuWith = func(f string) *template.Template {
|
||||
return m(m(viewutil.BaseRu.Clone()).ParseFS(fs, f))
|
||||
}
|
||||
)
|
||||
|
||||
viewCardChain = viewutil.
|
||||
En(
|
||||
m(m(baseEn.Clone()).ParseFS(fs, "view_card.html"))).
|
||||
Ru(
|
||||
m(m(m(baseRu.Clone()).ParseFS(fs, "view_card.html")).Parse(categoriesRu)))
|
||||
En(copyEnWith("view_card.html")).
|
||||
Ru(m(copyRuWith("view_card.html").Parse(ruTranslation)))
|
||||
viewListChain = viewutil.
|
||||
En(
|
||||
m(m(baseEn.Clone()).ParseFS(fs, "view_list.html"))).
|
||||
Ru(
|
||||
m(m(m(baseRu.Clone()).ParseFS(fs, "view_list.html")).Parse(categoriesRu)))
|
||||
En(copyEnWith("view_list.html")).
|
||||
Ru(m(copyRuWith("view_list.html").Parse(ruTranslation)))
|
||||
viewPageChain = viewutil.
|
||||
En(
|
||||
m(m(baseEn.Clone()).ParseFS(fs, "view_page.html"))).
|
||||
Ru(
|
||||
m(m(m(baseRu.Clone()).ParseFS(fs, "view_page.html")).Parse(categoriesRu)))
|
||||
En(copyEnWith("view_page.html")).
|
||||
Ru(m(copyRuWith("view_page.html").Parse(ruTranslation)))
|
||||
}
|
||||
|
||||
type cardData struct {
|
||||
@ -59,6 +57,7 @@ type cardData struct {
|
||||
GivenPermissionToModify bool
|
||||
}
|
||||
|
||||
// CategoryCard is the little sidebar that is shown nearby the hypha view.
|
||||
func CategoryCard(meta viewutil.Meta, hyphaName string) string {
|
||||
var buf strings.Builder
|
||||
err := viewCardChain.Get(meta).ExecuteTemplate(&buf, "category card", cardData{
|
||||
|
Loading…
Reference in New Issue
Block a user