i18n
i18n copied to clipboard
additional method
method use
router.GET("/exist/:lang", func(ctx *gin.Context) {
ctx.String(http.StatusOK, "%v", ginI18n.HasLang(ctx, ctx.Param("lang")))
})
// get the default and current language
router.GET("/lang/default", func(context *gin.Context) {
context.String(http.StatusOK, "%s", GetDefaultLanguage(context).String())
})
// get the current language
router.GET("/lang/current", func(context *gin.Context) {
context.String(http.StatusOK, "%s", GetCurrentLanguage(context).String())
})
router.GET("/messageType/:name", func(context *gin.Context) {
context.String(http.StatusOK, MustGetMessage(context, &i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "welcomeWithName",
},
TemplateData: map[string]string{
"name": context.Param("name"),
},
}))
})