From 18117832e5a2add199ad5cb065d97fd1a365b4f9 Mon Sep 17 00:00:00 2001 From: Mohammad Foroughi Date: Sun, 30 Oct 2022 04:33:31 +0330 Subject: [PATCH] update: add a function to translate --- web/controller/base.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/controller/base.go b/web/controller/base.go index 5d2ccec2..210a0fb6 100644 --- a/web/controller/base.go +++ b/web/controller/base.go @@ -21,3 +21,13 @@ func (a *BaseController) checkLogin(c *gin.Context) { c.Next() } } + + +func I18n(c *gin.Context , name string, data ...string) string{ + anyfunc, _ := c.Get("I18n") + i18n, _ := anyfunc.(func(key string, params ...string) (string, error)) + + message, _ := i18n("pages.index.title") + + return message; +}