add localizer middleware to web.go

This commit is contained in:
Hamidreza Ghavami 2023-05-20 19:46:05 +04:30
parent 92eaff9608
commit 4865754b3d
No known key found for this signature in database
GPG Key ID: 402C6797325182D9

View File

@ -207,6 +207,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