mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 21:07:03 +00:00
Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
29
_examples/miscellaneous/i18n/main_test.go
Normal file
29
_examples/miscellaneous/i18n/main_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/httptest"
|
||||
)
|
||||
|
||||
func TestI18n(t *testing.T) {
|
||||
app := newApp()
|
||||
|
||||
expectedf := "From the language %s translated output: %s"
|
||||
var (
|
||||
elgr = fmt.Sprintf(expectedf, "el-GR", "γεια, iris")
|
||||
enus = fmt.Sprintf(expectedf, "en-US", "hello, iris")
|
||||
zhcn = fmt.Sprintf(expectedf, "zh-CN", "您好,iris")
|
||||
)
|
||||
|
||||
e := httptest.New(t, app)
|
||||
// default is en-US
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(enus)
|
||||
// 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("/").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)
|
||||
}
|
||||
Reference in New Issue
Block a user