1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

use jet v5.0.2 (no breaking changes)

relative to: https://github.com/kataras/iris/pull/1616
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-10 10:12:06 +03:00
parent 62d1185d25
commit 333be428c4
6 changed files with 15 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ import (
/*
Iris I18n supports text/template inside the translation values.
Follow this tutorial to learn how to use that feature.
Follow this example to learn how to use that feature.
*/
func main() {
@@ -31,8 +31,8 @@ func newApp() *iris.Application {
// like we do here.
//
// Note that this is only for english,
// but you can accept the language code
// and use a map with dictionaries to
// but you can use the "current" locale
// and make a map with dictionaries to
// pluralize words based on the given language.
return pluralize.Pluralize(word, count, true)
},
@@ -48,5 +48,12 @@ func newApp() *iris.Application {
ctx.WriteString(text)
})
app.Get("/singular", func(ctx iris.Context) {
text := ctx.Tr("HiDogs", iris.Map{
"count": 1,
}) // prints "Hi 1 dog".
ctx.WriteString(text)
})
return app
}

View File

@@ -12,6 +12,8 @@ func TestI18nLoaderFuncMap(t *testing.T) {
e := httptest.New(t, app)
e.GET("/").Expect().Status(httptest.StatusOK).
Body().Equal("Hi 2 dogs")
e.GET("/singular").Expect().Status(httptest.StatusOK).
Body().Equal("Hi 1 dog")
e.GET("/").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK).
Body().Equal("Γειά 2 σκυλί")
}