add example for: #1614

This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-09-03 13:39:42 +03:00
parent dcd8fc4daa
commit d617a77209
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
5 changed files with 15 additions and 4 deletions

View File

@ -1 +1,2 @@
hi = γεια, %s
hi = γεια, %s
userProfilePublicDescription = <a href="%s">περιγραφή προφιλ</a>

View File

@ -1 +1,2 @@
hi = hello, %s
hi = hello, %s
userProfilePublicDescription = <a href="%s">profile description</a>

View File

@ -1 +1,2 @@
hi = 您好,%s
hi = 您好,%s
userProfilePublicDescription = <a href="%s">个人资料描述</a>

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"html/template"
"github.com/kataras/iris/v12"
)
@ -78,6 +79,9 @@ func newApp() *iris.Application {
app.Get("/templates", func(ctx iris.Context) {
ctx.View("index.html", iris.Map{
"tr": ctx.Tr, // word, arguments... {call .tr "hi" "iris"}}
"trUnsafe": func(message string, args ...interface{}) template.HTML {
return template.HTML(ctx.Tr(message, args...))
},
})
// Note that,

View File

@ -6,4 +6,8 @@
<h3>Test translate of any language template function <i>[static]</i> ("language", "word", arguments...) <br/> <code>tr "zh-CN" "hi" "iris"</code></h3>
{{tr "zh-CN" "hi" "iris"}}
{{tr "zh-CN" "hi" "iris"}}
<h3>Test HTML link ("word", arguments...) <br/> <code>call .trUnsafe "trUnsafe" "userProfilePublicDescription" "https://iris-go.com"</code></h3>
{{call .trUnsafe "userProfilePublicDescription" "https://iris-go.com"}}