Beispiel #1
0
func (a *Language) Middleware() echo.MiddlewareFunc {
	return echo.MiddlewareFunc(func(h echo.Handler) echo.Handler {
		return echo.HandlerFunc(func(c echo.Context) error {
			lang := a.DetectURI(c.Response(), c.Request())
			c.SetFunc("Lang", func() string {
				return lang
			})
			c.SetFunc("T", func(key string, args ...interface{}) string {
				return i18n.T(lang, key, args...)
			})
			X.X(c).Language = lang
			return h.Handle(c)
		})
	})
}
Beispiel #2
0
func (this *Model) T(key string, args ...interface{}) string {
	return i18n.T(this.Context.Language, key, args...)
}