You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Pluralization uses yml for template configuration, uses ctx.Tr method for rendering, returns no data.
iris.Version
e.g. v12.2.5 or main
Additional context
code:
package main
import (
"github.com/kataras/iris/v12"
"strings"
)
const (
female = iota + 1
male
)
func main() {
app := iris.New()
err := app.I18n.Load("./locales/*/*", "en-US")
// ^ here we only use a single locale for the sake of the example,
// on a real app you can register as many languages as you want to support.
if err != nil {
panic(err)
}
app.Get("/", func(ctx iris.Context) {
a := ctx.Tr("VarTemplatePlural", iris.Map{
"PluralCount": 5,
"Names": []string{"John", "Peter"},
"InlineJoin": func(arr []string) string {
return strings.Join(arr, ", ")
},
})
// Outputs: John, Peter are awesome
b := ctx.Tr("VarTemplatePlural", 1, female)
// Outputs: She is awesome!
c := ctx.Tr("VarTemplatePlural", 2, female, 5)
// Outputs: other (She) has 5 houses.
ctx.WriteString(a + b + c)
})
app.Listen(`:8080`)
}
welcome.yml:
Vars:
- Houses:
one: "house"
other: "houses"
- Gender:
"=1": "She"
"=2": "He"
VarTemplatePlural:
one: "${Gender} is awesome!"
other: "other (${Gender}) has %[3]d ${Houses}."
"=5": "{{call .InlineJoin .Names}} are awesome."
The text was updated successfully, but these errors were encountered:
Hello @beifeng778 I ran your example and it seems that there is no issue here, the response is: John, Peter are awesome.She is awesome!other (She) has 5 houses. Can you explain the problem a bit more?
Describe the bug
Pluralization uses yml for template configuration, uses ctx.Tr method for rendering, returns no data.
iris.Version
Additional context
code:
welcome.yml:
The text was updated successfully, but these errors were encountered: