1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-22 19:36:00 +00:00

example: i18n: nested .ini template key-values

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-14 22:00:20 +03:00
parent 44d5ebdc9c
commit 0f7cf7f35c
5 changed files with 43 additions and 3 deletions

View File

@@ -287,11 +287,15 @@ func (l *defaultLocale) GetMessageContext(ctx *context.Context, key string, args
}
func (l *defaultLocale) getMessage(langInput, key string, args ...interface{}) string {
// search on templates.
if tmpl, ok := l.templateKeys[key]; ok {
var data interface{}
if len(args) > 0 {
data = args[0]
}
buf := new(bytes.Buffer)
err := tmpl.Execute(buf, args[0])
err := tmpl.Execute(buf, data)
if err != nil {
return err.Error()
}