feat: 国际化模拟测试接口
This commit is contained in:
@@ -73,7 +73,8 @@ func Setup(router *gin.Engine) {
|
|||||||
// 通用请求
|
// 通用请求
|
||||||
commonGroup := router.Group("/common")
|
commonGroup := router.Group("/common")
|
||||||
{
|
{
|
||||||
commonGroup.GET("/hash", middleware.PreAuthorize(nil), controller.NewCommont.Hash)
|
commonGroup.POST("/hash", middleware.PreAuthorize(nil), controller.NewCommont.Hash)
|
||||||
|
commonGroup.GET("/i18n", controller.NewCommont.I18n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 文件操作处理
|
// 文件操作处理
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"ems.agt/src/framework/i18n"
|
||||||
|
"ems.agt/src/framework/utils/ctx"
|
||||||
"ems.agt/src/framework/vo/result"
|
"ems.agt/src/framework/vo/result"
|
||||||
commonService "ems.agt/src/modules/common/service"
|
commonService "ems.agt/src/modules/common/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -21,11 +23,35 @@ type CommontController struct {
|
|||||||
|
|
||||||
// 哈希加密
|
// 哈希加密
|
||||||
//
|
//
|
||||||
// GET /hash
|
// POST /hash
|
||||||
func (s *CommontController) Hash(c *gin.Context) {
|
func (s *CommontController) Hash(c *gin.Context) {
|
||||||
c.String(200, "commont Hash")
|
c.String(200, "commont Hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 多语言处理
|
||||||
|
//
|
||||||
|
// GET /i18n
|
||||||
|
func (s *CommontController) I18n(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
|
||||||
|
i18nLang := i18n.TKey(language, "i18n")
|
||||||
|
hello := i18n.TKey(language, "hello")
|
||||||
|
ivs := i18n.TTemplate(language, "errorFields", nil)
|
||||||
|
errorFields := i18n.TTemplate(language, "errorFields", map[string]any{
|
||||||
|
"num": 1000,
|
||||||
|
"hello": "你好",
|
||||||
|
"h2o2": false,
|
||||||
|
"fileName": " ====",
|
||||||
|
})
|
||||||
|
c.JSON(200, map[string]any{
|
||||||
|
"lang": language,
|
||||||
|
"i18nLang": i18nLang,
|
||||||
|
"ivs": ivs,
|
||||||
|
"hello": hello,
|
||||||
|
"errorFields": errorFields,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 系统可暴露的配置信息
|
// 系统可暴露的配置信息
|
||||||
//
|
//
|
||||||
// GET /sys-conf
|
// GET /sys-conf
|
||||||
|
|||||||
Reference in New Issue
Block a user