Passport/pkg/i18n/middleware.go
2024-04-20 14:05:50 +08:00

16 lines
288 B
Go

package i18n
import (
"github.com/gofiber/fiber/v2"
"github.com/nicksnyder/go-i18n/v2/i18n"
)
func I18nMiddleware(c *fiber.Ctx) error {
accept := c.Get(fiber.HeaderAcceptLanguage)
localizer := i18n.NewLocalizer(Bundle, accept)
c.Locals("localizer", localizer)
return c.Next()
}