mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-31 11:29:09 +00:00
L10n experiment no. 6 (?)
Use the template system for default English keys and then redefine them with Russian versions. This is kinda weird.
This commit is contained in:
parent
15496ec02a
commit
40bb20a89c
@ -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
|
||||
}{
|
||||
|
@ -29,11 +29,9 @@
|
||||
{{define "category page"}}
|
||||
{{$catName := .CatName}}
|
||||
<main class="main-width category">
|
||||
<h1>Category <i>{{$catName}}</i></h1>
|
||||
{{if len .Hyphae}}
|
||||
<p>This page lists all hyphae in the category.</p>
|
||||
{{else}}
|
||||
<p>This category has no hyphae.</p>
|
||||
<h1>{{block "cat" .}}Category{{end}} <i>{{beautifulName $catName}}</i></h1>
|
||||
{{if len .Hyphae | not}}
|
||||
<p>{{block "empty cat" .}}This category is empty{{end}}</p>
|
||||
{{end}}
|
||||
<ul class="category__entries">
|
||||
{{range .Hyphae}}
|
||||
@ -43,10 +41,11 @@
|
||||
{{end}}
|
||||
<li class="category__entry category__add-to-cat">
|
||||
<form method="POST" action="/add-to-category" class="category__add-form">
|
||||
<input type="text" name="hypha" id="_hypha-name" placeholder="Hypha name">
|
||||
<input type="text" name="hypha" id="_hypha-name"
|
||||
placeholder="{{block `hypha name` .}}Hypha name{{end}}">
|
||||
<input type="hidden" name="cat" value="{{$catName}}">
|
||||
<input type="hidden" name="redirect-to" value="/category/{{$catName}}">
|
||||
<input type="submit" value="Add hypha to category">
|
||||
<input type="submit" value="{{block `add hypha` .}}Add to the category{{end}}">
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user