diff options
Diffstat (limited to 'api/context.go')
-rw-r--r-- | api/context.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/api/context.go b/api/context.go index 561884c14..a3311a971 100644 --- a/api/context.go +++ b/api/context.go @@ -15,6 +15,7 @@ import ( "github.com/mattermost/platform/model" "github.com/mattermost/platform/store" "github.com/mattermost/platform/utils" + goi18n "github.com/nicksnyder/go-i18n/i18n" ) var sessionCache *utils.Cache = utils.NewLru(model.SESSION_CACHE_SIZE) @@ -29,12 +30,14 @@ type Context struct { teamURL string siteURL string SessionTokenIndex int64 + T goi18n.TranslateFunc } type Page struct { TemplateName string Props map[string]string ClientCfg map[string]string + ClientLicense map[string]string User *model.User Team *model.Team Channel *model.Channel @@ -80,10 +83,10 @@ type handler struct { } func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - l4g.Debug("%v", r.URL.Path) c := &Context{} + c.T = utils.GetTranslations(w, r) c.RequestId = model.NewId() c.IpAddress = GetIpAddress(r) @@ -203,6 +206,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if c.Err != nil { + c.Err.Translate(c.T) c.Err.RequestId = c.RequestId c.LogError(c.Err) c.Err.Where = r.URL.Path @@ -370,7 +374,7 @@ func (c *Context) RemoveSessionCookie(w http.ResponseWriter, r *http.Request) { } func (c *Context) SetInvalidParam(where string, name string) { - c.Err = model.NewAppError(where, "Invalid "+name+" parameter", "") + c.Err = model.NewLocAppError(where, "api.context.invalid_param", map[string]interface{}{"Name": name}, "") c.Err.StatusCode = http.StatusBadRequest } |