Marc Coquand
unread,Nov 21, 2024, 3:14:46 PMNov 21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Hi!
I am trying to more easily add text into my go html templates, that I
can translate at a later stage.
So I tried adding the following in my handler
```go
p := i18nPrinter(c) // *message.Printer, uses golang's i18n library
c.HTML(http.StatusOK, "my-template.tmpl", gin.H{
"p": p,
})
```
And then within my-template, I do the following to print a specific string.
```gohtml
<p>{{ .p.Sprintf "Hello world" }}</p>
```
And then to generate translations:
```sh
$ go generate i18n/i18n.go
```
I would expect "Hello world" to show up as a list of items that need
translations, however, it seems not to.
It'd be nice if I could add the Sprintf statements directly within the
go templates, as that would lower the indirection needed.
Is there a way to accomplish that? Or is it unsupported?
Sincerely,
--
Marc