mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
add example for: #1614
This commit is contained in:
parent
dcd8fc4daa
commit
d617a77209
|
@ -1 +1,2 @@
|
||||||
hi = γεια, %s
|
hi = γεια, %s
|
||||||
|
userProfilePublicDescription = <a href="%s">περιγραφή προφιλ</a>
|
|
@ -1 +1,2 @@
|
||||||
hi = hello, %s
|
hi = hello, %s
|
||||||
|
userProfilePublicDescription = <a href="%s">profile description</a>
|
|
@ -1 +1,2 @@
|
||||||
hi = 您好,%s
|
hi = 您好,%s
|
||||||
|
userProfilePublicDescription = <a href="%s">个人资料描述</a>
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
)
|
)
|
||||||
|
@ -78,6 +79,9 @@ func newApp() *iris.Application {
|
||||||
app.Get("/templates", func(ctx iris.Context) {
|
app.Get("/templates", func(ctx iris.Context) {
|
||||||
ctx.View("index.html", iris.Map{
|
ctx.View("index.html", iris.Map{
|
||||||
"tr": ctx.Tr, // word, arguments... {call .tr "hi" "iris"}}
|
"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,
|
// Note that,
|
||||||
|
|
|
@ -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>
|
<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"}}
|
Loading…
Reference in New Issue
Block a user