1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 20:05:59 +00:00

i18n several improvements

trigger #1369


Former-commit-id: af16dd8de1a0096d33c4e4c97f29ec12a73302f4
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-11-22 02:57:26 +02:00
parent 377db7f822
commit 4e9a6be9aa
5 changed files with 273 additions and 141 deletions

View File

@@ -11,12 +11,19 @@ import (
func TestI18n(t *testing.T) {
app := newApp()
expectedf := "From the language %s translated output: %s"
const (
expectedf = "From the language %s translated output: %s"
enUS = "hello, iris"
elGR = "γεια, iris"
zhCN = "您好iris"
)
var (
tests = map[string]string{
"en-US": fmt.Sprintf(expectedf, "en-US", "hello, iris"),
"el-GR": fmt.Sprintf(expectedf, "el-GR", "γεια, iris"),
"zh-CN": fmt.Sprintf(expectedf, "zh-CN", "您好iris"),
"en-US": fmt.Sprintf(expectedf, "en-US", enUS),
"el-GR": fmt.Sprintf(expectedf, "el-GR", elGR),
"zh-CN": fmt.Sprintf(expectedf, "zh-CN", zhCN),
}
elgrMulti = fmt.Sprintf("From the language: %s, translated output:\n%s=%s\n%s=%s", "el-GR",
@@ -71,4 +78,9 @@ func TestI18n(t *testing.T) {
Body().Equal(elgrMulti)
e.GET("/en/multi").Expect().Status(httptest.StatusOK).
Body().Equal(enusMulti)
e.GET("/el-GRtemplates").Expect().Status(httptest.StatusNotFound)
e.GET("/el-templates").Expect().Status(httptest.StatusNotFound)
e.GET("/el/templates").Expect().Status(httptest.StatusOK).Body().Contains(elGR).Contains(zhCN)
}