mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
update test to cover the multi files per language new feature - requested at: https://github.com/kataras/iris/issues/815
Former-commit-id: 6516e648a30a0886ad55146d463bfa696972d1c6
This commit is contained in:
parent
42e7faec52
commit
56871ce4d7
|
@ -15,15 +15,35 @@ func TestI18n(t *testing.T) {
|
||||||
elgr = fmt.Sprintf(expectedf, "el-GR", "γεια, iris")
|
elgr = fmt.Sprintf(expectedf, "el-GR", "γεια, iris")
|
||||||
enus = fmt.Sprintf(expectedf, "en-US", "hello, iris")
|
enus = fmt.Sprintf(expectedf, "en-US", "hello, iris")
|
||||||
zhcn = fmt.Sprintf(expectedf, "zh-CN", "您好,iris")
|
zhcn = fmt.Sprintf(expectedf, "zh-CN", "您好,iris")
|
||||||
|
|
||||||
|
elgrMulti = fmt.Sprintf("From the language: %s, translated output:\n%s=%s\n%s=%s", "el-GR",
|
||||||
|
"key1",
|
||||||
|
"αυτό είναι μια τιμή από το πρώτο αρχείο: locale_multi_first",
|
||||||
|
"key2",
|
||||||
|
"αυτό είναι μια τιμή από το δεύτερο αρχείο μετάφρασης: locale_multi_second")
|
||||||
|
enusMulti = fmt.Sprintf("From the language: %s, translated output:\n%s=%s\n%s=%s", "en-US",
|
||||||
|
"key1",
|
||||||
|
"this is a value from the first file: locale_multi_first",
|
||||||
|
"key2",
|
||||||
|
"this is a value from the second file: locale_multi_second")
|
||||||
)
|
)
|
||||||
|
|
||||||
e := httptest.New(t, app)
|
e := httptest.New(t, app)
|
||||||
// default is en-US
|
// default is en-US
|
||||||
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
||||||
// default is en-US if lang query unable to be found
|
// default is en-US if lang query unable to be found
|
||||||
e.GET("/").WithQueryString("lang=un-EX").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
||||||
|
|
||||||
|
e.GET("/").WithQueryString("lang=el-GR").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal(elgr)
|
||||||
|
e.GET("/").WithQueryString("lang=en-US").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal(enus)
|
||||||
|
e.GET("/").WithQueryString("lang=zh-CN").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal(zhcn)
|
||||||
|
|
||||||
|
e.GET("/multi").WithQueryString("lang=el-GR").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal(elgrMulti)
|
||||||
|
e.GET("/multi").WithQueryString("lang=en-US").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal(enusMulti)
|
||||||
|
|
||||||
e.GET("/").WithQueryString("lang=el-GR").Expect().Status(httptest.StatusOK).Body().Equal(elgr)
|
|
||||||
e.GET("/").WithQueryString("lang=en-US").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
|
||||||
e.GET("/").WithQueryString("lang=zh-CN").Expect().Status(httptest.StatusOK).Body().Equal(zhcn)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user