diff options
author | Thomas Voss <mail@thomasvoss.com> | 2025-07-24 20:40:42 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2025-07-24 20:40:42 +0200 |
commit | 1229eac801771fd12bcc885d393ef1727c02eddc (patch) | |
tree | 785da8ceddd0a6db494cc5039f9154b661537175 | |
parent | 94a2f1efa0da1d1d91d2af736c0dab720c9512b2 (diff) |
Update the translation system
-rw-r--r-- | GNUmakefile | 5 | ||||
-rw-r--r-- | src/i18n/i18n.go | 14 | ||||
-rw-r--r-- | src/templates/coins-designs-ad.html.tmpl | 4 | ||||
-rw-r--r-- | src/templates/coins-designs-de.html.tmpl | 6 | ||||
-rw-r--r-- | src/templates/coins-designs-hr.html.tmpl | 8 | ||||
-rw-r--r-- | src/templates/coins-designs-nl.html.tmpl | 4 |
6 files changed, 24 insertions, 17 deletions
diff --git a/GNUmakefile b/GNUmakefile index c69b87c..46c685b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,14 +13,13 @@ all: euro-cash.eu exttmpl euro-cash.eu: $(cssfiles) $(templates) $(gofiles) $(sqlfiles) $(GO) build -all-i18n: exttmpl +po: exttmpl find . -name '*.html.tmpl' -exec ./exttmpl -out po/templates.pot {} + for bcp in en en-US nl; \ do \ mkdir -p "po/$$bcp"; \ msgmerge --update "po/$$bcp/messages.po" po/templates.pot; \ done - $(GO) build exttmpl: $(exttmpl) $(GO) build ./cmd/exttmpl @@ -41,4 +40,4 @@ clean: -or -name '*.tar.gz' \ \) -delete -.PHONY: all-i18n clean release
\ No newline at end of file +.PHONY: clean po release
\ No newline at end of file diff --git a/src/i18n/i18n.go b/src/i18n/i18n.go index 950d4e2..fdc02f6 100644 --- a/src/i18n/i18n.go +++ b/src/i18n/i18n.go @@ -339,7 +339,7 @@ func (l LocaleInfo) Language() string { func (p Printer) Sprintf(format string, args ...map[string]any) string { var bob strings.Builder vars := map[string]any{ - "-": "", + "-": "a", } for _, arg := range args { maps.Copy(vars, arg) @@ -430,8 +430,16 @@ func sprintfe(li LocaleInfo, bob *strings.Builder, v any) error { return nil } -func sprintfE(li LocaleInfo, bob *strings.Builder, _ any) error { - bob.WriteString("</a>") +func sprintfE(li LocaleInfo, bob *strings.Builder, v any) error { + s, ok := v.(string) + if !ok { + return errors.New("TODO") + } + for tag := range strings.SplitSeq(s, ",") { + bob.WriteString("</") + bob.WriteString(tag) + bob.WriteByte('>') + } return nil } diff --git a/src/templates/coins-designs-ad.html.tmpl b/src/templates/coins-designs-ad.html.tmpl index ab27555..d63110c 100644 --- a/src/templates/coins-designs-ad.html.tmpl +++ b/src/templates/coins-designs-ad.html.tmpl @@ -44,8 +44,8 @@ <li>{{ .Get "The arms of Catalonia" }}</li> <li>{{ .Get "The arms of the Viscounts of Béarn" }}</li> </ul> - {{ .Get "The bottom of the coat of arms has the motto ‘{LatinStart:r}VIRTVS VNITA FORTIOR{LatinEnd:r}’ (English: ‘UNITED VIRTUE IS STRONGER’)." - (map "LatinStart" `<span lang="la"><em>` "LatinEnd" `</em></span>`) }} + {{ .Get "The bottom of the coat of arms has the motto ‘{LatinStart:r}VIRTVS VNITA FORTIOR{LatinEnd:E}’ (English: ‘UNITED VIRTUE IS STRONGER’)." + (map "LatinStart" `<span lang="la"><em>` "LatinEnd" "em,span") }} </p> </main> {{ end }}
\ No newline at end of file diff --git a/src/templates/coins-designs-de.html.tmpl b/src/templates/coins-designs-de.html.tmpl index bb4bd85..995752f 100644 --- a/src/templates/coins-designs-de.html.tmpl +++ b/src/templates/coins-designs-de.html.tmpl @@ -4,7 +4,7 @@ <h1>{{ .Get "German Euro Coin Designs" }}</h1> </header> <main> - {{ $deargs := (map "GermanStart" `<span lang="de"><em>` "GermanEnd" `</em></span>`) }} + {{ $deargs := (map "GermanStart" `<span lang="de"><em>` "GermanEnd" "em,span") }} <div class="design-container"> <img alt="{{ .Get `German €0.01 coin` }}" src="/designs/de-001.avif"> @@ -53,11 +53,11 @@ {{ .Get "The gold coins feature the Brandenburg Gate, a symbol of Berlin and Germany as a whole, but also a symbol of German division and unity. The mint mark is located below the year." }} </p> <p> - {{ .Get "The bimetallic coins feature an interpretation of the German Federal Eagle (German: ‘{GermanStart:r}Bundesadler{GermanEnd:r}’). The eagle is a common motif in German heraldry — including in the German coat of arms — and represents strength and freedom. The mint mark is located to the right of the year." $deargs }} + {{ .Get "The bimetallic coins feature an interpretation of the German Federal Eagle (German: ‘{GermanStart:r}Bundesadler{GermanEnd:E}’). The eagle is a common motif in German heraldry — including in the German coat of arms — and represents strength and freedom. The mint mark is located to the right of the year." $deargs }} </p> <p> <!-- TODO: Get a picture of the edge-inscription --> - {{ .Get "The €2 coin also features an edge-inscription of Germany’s national motto and incipit of Germany’s national anthem. It reads ‘{GermanStart:r}EINIGKEIT UND RECHT UND FREIHEIT{GermanEnd:r}’ (English: ‘UNITY AND JUSTICE AND FREEDOM’)." $deargs }} + {{ .Get "The €2 coin also features an edge-inscription of Germany’s national motto and incipit of Germany’s national anthem. It reads ‘{GermanStart:r}EINIGKEIT UND RECHT UND FREIHEIT{GermanEnd:E}’ (English: ‘UNITY AND JUSTICE AND FREEDOM’)." $deargs }} </p> </main> {{ end }}
\ No newline at end of file diff --git a/src/templates/coins-designs-hr.html.tmpl b/src/templates/coins-designs-hr.html.tmpl index 3c8fae5..9f98a9b 100644 --- a/src/templates/coins-designs-hr.html.tmpl +++ b/src/templates/coins-designs-hr.html.tmpl @@ -4,7 +4,7 @@ <h1>{{ .Get "Croatian Euro Coin Designs" }}</h1> </header> <main> - {{ $hrargs := (map "CroatianStart" `<span lang="hr"><em>` "CroatianEnd" `</em></span>`) }} + {{ $hrargs := (map "CroatianStart" `<span lang="hr"><em>` "CroatianEnd" "em,span") }} <div class="design-container"> <img alt="{{ .Get `Croatian €0.01 coin` }}" src="/designs/hr-001.avif" /> <img alt="{{ .Get `Croatian €0.50 coin` }}" src="/designs/hr-050.avif" /> @@ -14,7 +14,7 @@ <img alt="{{ .Get `Croatian €2 coin` }}" src="/designs/hr-200.avif" /> </div> <p> - {{ .Get "The Croatian euro coins feature four different themes, with each design featuring the Croatian checkerboard and the country’s name in Croatian (‘{CroatianStart:r}HRVATSKA{CroatianEnd:r}’). All designs were selected after voting in a public design competition." + {{ .Get "The Croatian euro coins feature four different themes, with each design featuring the Croatian checkerboard and the country’s name in Croatian (‘{CroatianStart:r}HRVATSKA{CroatianEnd:E}’). All designs were selected after voting in a public design competition." $hrargs }} </p> <p> @@ -26,12 +26,12 @@ (map "Link" "https://www.wikipedia.org/wiki/Nikola_Tesla") }} </p> <p> - {{ .Get "The 1 euro coin was designed by Jagor Šunde, David Čemeljić and Fran Zekan and features a marten. The marten is the semi-official national animal of Croatia and the Kuna — their pre-Euro currency — was named after the marten (‘{CroatianStart:r}kuna zlatica{CroatianEnd:r}’ in Croatian)." + {{ .Get "The 1 euro coin was designed by Jagor Šunde, David Čemeljić and Fran Zekan and features a marten. The marten is the semi-official national animal of Croatia and the Kuna — their pre-Euro currency — was named after the marten (‘{CroatianStart:r}kuna zlatica{CroatianEnd:E}’ in Croatian)." $hrargs }} </p> <p> <!-- TODO: Include a photo of the edge inscription --> - {{ .Get "The 2 euro coin was designed by Ivan Šivak and features the map of Croatia. The coin also has an edge-inscription that reads ‘{CroatianStart:r}O LIJEPA O DRAGA O SLATKA SLOBODO{CroatianEnd:r}’ (English: ‘OH BEAUTIFUL, OH DEAR, OH SWEET FREEDOM’) which is a line from the play {Link:L}Dubravka{-:E} by Ivan Gundulić." + {{ .Get "The 2 euro coin was designed by Ivan Šivak and features the map of Croatia. The coin also has an edge-inscription that reads ‘{CroatianStart:r}O LIJEPA O DRAGA O SLATKA SLOBODO{CroatianEnd:E}’ (English: ‘OH BEAUTIFUL, OH DEAR, OH SWEET FREEDOM’) which is a line from the play {Link:L}Dubravka{-:E} by Ivan Gundulić." $hrargs (map "Link" "https://www.wikipedia.org/wiki/Dubravka_(drama)") }} </p> </main> diff --git a/src/templates/coins-designs-nl.html.tmpl b/src/templates/coins-designs-nl.html.tmpl index c99d308..e98e77b 100644 --- a/src/templates/coins-designs-nl.html.tmpl +++ b/src/templates/coins-designs-nl.html.tmpl @@ -4,7 +4,7 @@ <h1>{{ .Get "Dutch Euro Coin Designs" }}</h1> </header> <main> - {{ $nlargs := (map "DutchStart" `<span lang="nl"><em>` "DutchEnd" `</em></span>`) }} + {{ $nlargs := (map "DutchStart" `<span lang="nl"><em>` "DutchEnd" "em,span") }} <div class="design-container"> <img alt="Dutch €0.50 coin (Queen Beatrix)" @@ -30,7 +30,7 @@ </p> <p> <!-- TODO: Get a picture of the edge-inscription --> - {{ .Get "Coins featuring both monarchs contain text reading ‘{DutchStart:r}BEATRIX KONINGIN DER NEDERLANDEN{DutchEnd:r}’ (English: ‘BEATRIX QUEEN OF THE NETHERLANDS’) and ‘{DutchStart:r}Willem-Alexander Koning der Nederlanden{DutchEnd:r}’ (English: ‘Willem-Alexander King of the Netherlands’) respectively. The €2 coins also feature an edge-inscription reading ‘{DutchStart:r}GOD ⋆ ZIJ ⋆ MET ⋆ ONS ⋆{DutchEnd:r}’ (English: ‘GOD ⋆ IS ⋆ WITH ⋆ US ⋆’)." + {{ .Get "Coins featuring both monarchs contain text reading ‘{DutchStart:r}BEATRIX KONINGIN DER NEDERLANDEN{DutchEnd:E}’ (English: ‘BEATRIX QUEEN OF THE NETHERLANDS’) and ‘{DutchStart:r}Willem-Alexander Koning der Nederlanden{DutchEnd:E}’ (English: ‘Willem-Alexander King of the Netherlands’) respectively. The €2 coins also feature an edge-inscription reading ‘{DutchStart:r}GOD ⋆ ZIJ ⋆ MET ⋆ ONS ⋆{DutchEnd:E}’ (English: ‘GOD ⋆ IS ⋆ WITH ⋆ US ⋆’)." $nlargs }} </p> <p> |