From 37df33e09316c105294d4a73cf56819b9a738a8c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 2 Aug 2025 01:20:00 +0200 Subject: Improve table formatting --- src/templates.go | 23 ++++++++ src/templates/coins-designs-ee.html.tmpl | 92 +++++++++++++------------------- 2 files changed, 61 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/templates.go b/src/templates.go index a3bc52d..ec081f1 100644 --- a/src/templates.go +++ b/src/templates.go @@ -33,6 +33,7 @@ var ( "safe": asHTML, "toUpper": strings.ToUpper, "tuple": templateMakeTuple, + "withTranslation": withTranslation, "withTranslations": withTranslations, } ) @@ -119,6 +120,28 @@ func ifElse(b bool, x, y any) any { return y } +func withTranslation(tag, bcp, text string, trans template.HTML) template.HTML { + var bob strings.Builder + bob.WriteByte('<') + bob.WriteString(tag) + bob.WriteString(`>`) + bob.WriteString(text) + bob.WriteString("") + + if text != string(trans) { + bob.WriteString(`
`) + bob.WriteString(string(trans)) + bob.WriteString("") + } + + bob.WriteString("') + return template.HTML(bob.String()) +} + func withTranslations(tag string, text string, translations ...[]any) template.HTML { var bob strings.Builder bob.WriteByte('<') diff --git a/src/templates/coins-designs-ee.html.tmpl b/src/templates/coins-designs-ee.html.tmpl index ad1a1dc..b478ff3 100644 --- a/src/templates/coins-designs-ee.html.tmpl +++ b/src/templates/coins-designs-ee.html.tmpl @@ -36,122 +36,106 @@ {{ .Get "Position" }} - {{ .Get "Name" }}
{{ .Get "Translation" }} + + {{ .Get "Name" }}
+ {{ .Get "Translation" }} + {{ .Get "Author(s)" }} {{ .Get "Votes" }} {{ .Get "Votes (%)" }} - {{ $args := (map "Break" "
") }} + {{ $args := map "Break" "
" }} 1 - {{/* TRANSLATORS: This is a place name. If you’re translating for a latin-script language, translate this to ‘{Null}’, otherwise transliterate this into your respective alphabet. */}} - Hara 2{{ .Get "{Break:r}Hara 2" $args }} + {{/* TRANSLATORS: Name of a coin design. Don’t translate unless you use a non-latin script */}} + {{ withTranslation "td" "et" "Hara 2" + (.Get "Hara 2") }} {{ .Get "Lembit Lõhmus" }} {{ .Printer.Itoa 12482 }} - {{ .Printer.Ftoa 27.46 }} + {{ .Printer.Ftop 27.46 }} 2 - - Järjepidevus - {{/* TRANSLATORS: Estonian translators should replace the entire translation with ‘{Null}’ */}} - {{ .Get "{Break:r}Consistency" $args }} - + {{ withTranslation "td" "et" "Järjepidevus" + (.Get "Consistency") }} {{ .Get "Tiit Jürna" }} {{ .Printer.Itoa 7477 }} - {{ .Printer.Ftoa 16.45 }} + {{ .Printer.Ftop 16.45 }} 3 - - In corpore - {{ .Get "{Break:r}In the Body" $args }} - + {{ withTranslation "td" "la" "In corpore" + (.Get "In the Body") }} {{ .Get "Jaan Meristo" }} {{ .Printer.Itoa 7284 }} - {{ .Printer.Ftoa 16.03 }} + {{ .Printer.Ftop 16.03 }} 4 - - Tomson 5791 - {{/* TRANSLATORS: This name. If you’re translating for a latin-script language, translate this to ‘{Null}’, otherwise transliterate this into your respective alphabet. */}} - {{ .Get "{Break:r}Tomson 5791" $args }} - + {{/* TRANSLATORS: Name of a coin design. Don’t translate unless you use a non-latin script */}} + {{ withTranslation "td" "et" "Tomson 5791" + (.Get "Tomson 5791") }} {{ .Get "Taavi Torim" }} {{ .Printer.Itoa 6219 }} - {{ .Printer.Ftoa 13.68 }} + {{ .Printer.Ftop 13.68 }} 5 - - Eesti keel - {{/* TRANSLATORS: Estonian translators should replace the entire translation with ‘{Null}’ */}} - {{ .Get "{Break:r}Estonian" $args }} - + {{/* TRANSLATORS: Name of a coin design. Don’t translate unless you use a non-latin script */}} + {{ withTranslation "td" "et" "Eesti keel" + (.GetC "Estonian" "Language Name") }} {{ .Get "Jaak Peep, Villem Valme" }} {{ .Printer.Itoa 5997 }} - {{ .Printer.Ftoa 13.19 }} + {{ .Printer.Ftop 13.19 }} 6 261948 {{ .Get "Mai Järmut, Villu Järmut" }} {{ .Printer.Itoa 3036 }} - {{ .Printer.Ftoa 6.68 }} + {{ .Printer.Ftop 6.68 }} 7 - - Linnutee - {{/* TRANSLATORS: Estonian translators should replace the entire translation with ‘{Null}’ */}} - {{ .Get "{Break:r}Bird Road" $args }} - + {{ withTranslation "td" "et" "Linnutee" + (.Get "Bird Road") }} {{ .Get "Tiit Jürna" }} {{ .Printer.Itoa 1323 }} - {{ .Printer.Ftoa 2.91 }} + {{ .Printer.Ftop 2.91 }} 8 - - Leopardid-2 - {{/* TRANSLATORS: Estonian translators should replace the entire translation with ‘{Null}’ */}} - {{ .Get "{Break:r}Leopards-2" $args }} - + {{ withTranslation "td" "et" "Leopardid-2" + (.Get "Leopards-2") }} {{ .Get "Jaarno Ester" }} {{ .Printer.Itoa 759 }} - {{ .Printer.Ftoa 1.67 }} + {{ .Printer.Ftop 1.67 }} 9 - - Nova - {{/* TRANSLATORS: This name. If you’re translating for a latin-script language, translate this to ‘{Null}’, otherwise transliterate this into your respective alphabet. */}} - {{ .Get "{Break:r}Nova" $args }} - + {{/* TRANSLATORS: Name of a coin design. Don’t translate unless you use a non-latin script */}} + {{ withTranslation "td" "et" "Nova" + (.Get "Nova") }} {{ .Get "Rene Haljasmäe" }} {{ .Printer.Itoa 498 }} - {{ .Printer.Ftoa 1.1 }} + {{ .Printer.Ftop 1.1 }} 10 - - Lill rukkis - {{/* TRANSLATORS: Estonian translators should replace the entire translation with ‘{Null}’ */}} - {{ .Get "{Break:r}A Flower in the Rye" $args }} - + {{ withTranslation "td" "et" "Lill rukkis" + (.Get "A Flower in the Rye") }} {{ .Get "Margus Kadarik" }} {{ .Printer.Itoa 378 }} - {{ .Printer.Ftoa 0.83 }} + {{ .Printer.Ftop 0.83 }} {{ .Get "Total" }} {{ .Printer.Itoa 45453 }} - {{ .Printer.Ftoa 100.0 }} + {{ .Printer.Ftop 100.0 }} -- cgit v1.2.3