add localizer middleware to web.go

This commit is contained in:
Hamidreza Ghavami
2023-05-21 06:38:02 +04:30
parent f77cec681a
commit 068decfb5e

View File

@@ -184,6 +184,13 @@ func (s *Server) initRouter() (*gin.Engine, error) {
return nil, err
}
// Apply locale middleware for i18n
webI18nFunc := func(key string, params ...string) string {
return locale.I18n(locale.Web, key, params...)
}
engine.FuncMap["i18n"] = webI18nFunc
engine.Use(locale.LocalizerMiddleware())
// set static files and template
if config.IsDebug() {
// for development