diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/api.go | 1 | ||||
-rw-r--r-- | api/context.go | 4 | ||||
-rw-r--r-- | api/post.go | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/api/api.go b/api/api.go index d0f41bcab..f537bbfdc 100644 --- a/api/api.go +++ b/api/api.go @@ -24,6 +24,7 @@ func NewServerTemplatePage(templateName string) *ServerTemplatePage { TemplateName: templateName, Props: make(map[string]string), ClientCfg: utils.ClientCfg, + Locale: model.DEFAULT_LOCALE, } } diff --git a/api/context.go b/api/context.go index b152d6da8..f47ed1c30 100644 --- a/api/context.go +++ b/api/context.go @@ -31,6 +31,7 @@ type Context struct { siteURL string SessionTokenIndex int64 T goi18n.TranslateFunc + Locale string } type Page struct { @@ -43,6 +44,7 @@ type Page struct { Channel *model.Channel PostID string SessionTokenIndex int64 + Locale string } func ApiAppHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler { @@ -86,7 +88,7 @@ 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.T, c.Locale = utils.GetTranslationsAndLocale(w, r) c.RequestId = model.NewId() c.IpAddress = GetIpAddress(r) diff --git a/api/post.go b/api/post.go index 42c3c304d..ecdb0925a 100644 --- a/api/post.go +++ b/api/post.go @@ -392,7 +392,7 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team // copy the context and create a mock session for posting the message mockSession := model.Session{UserId: hook.CreatorId, TeamId: hook.TeamId, IsOAuth: false} - newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0, c.T} + newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0, c.T, c.Locale} if text, ok := respProps["text"]; ok { if _, err := CreateWebhookPost(newContext, post.ChannelId, text, respProps["username"], respProps["icon_url"], post.Props, post.Type); err != nil { |