summaryrefslogtreecommitdiffstats
path: root/api/preference.go
diff options
context:
space:
mode:
authorElias Nahum <nahumhbl@gmail.com>2016-01-22 01:37:11 -0300
committerElias Nahum <nahumhbl@gmail.com>2016-01-22 01:37:11 -0300
commit6fd328ddaa61cd75c24cd2d9b8fdc0f73c7ab974 (patch)
tree04014253d528a8f8f79f7c26b02339e2945b20a5 /api/preference.go
parentc8d22ed1fba591e7a6b18afc5e6a6d541c11645c (diff)
downloadchat-6fd328ddaa61cd75c24cd2d9b8fdc0f73c7ab974.tar.gz
chat-6fd328ddaa61cd75c24cd2d9b8fdc0f73c7ab974.tar.bz2
chat-6fd328ddaa61cd75c24cd2d9b8fdc0f73c7ab974.zip
Refactoring api to use translations (chunk 2)
- Add spanish translations - Does not include tests - Add func to get the translations for a user locale
Diffstat (limited to 'api/preference.go')
-rw-r--r--api/preference.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/api/preference.go b/api/preference.go
index f5c96f1dd..9550b6c92 100644
--- a/api/preference.go
+++ b/api/preference.go
@@ -7,11 +7,12 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"net/http"
)
func InitPreference(r *mux.Router) {
- l4g.Debug("Initializing preference api routes")
+ l4g.Debug(utils.T("api.preference.init.debug"))
sr := r.PathPrefix("/preferences").Subrouter()
sr.Handle("/", ApiUserRequired(getAllPreferences)).Methods("GET")
@@ -33,14 +34,16 @@ func getAllPreferences(c *Context, w http.ResponseWriter, r *http.Request) {
func savePreferences(c *Context, w http.ResponseWriter, r *http.Request) {
preferences, err := model.PreferencesFromJson(r.Body)
if err != nil {
- c.Err = model.NewAppError("savePreferences", "Unable to decode preferences from request", err.Error())
+ c.Err = model.NewLocAppError("savePreferences", "api.preference.save_preferences.decode.app_error", nil, err.Error())
c.Err.StatusCode = http.StatusBadRequest
return
}
for _, preference := range preferences {
if c.Session.UserId != preference.UserId {
- c.Err = model.NewAppError("savePreferences", "Unable to set preferences for other user", "session.user_id="+c.Session.UserId+", preference.user_id="+preference.UserId)
+ c.Err = model.NewLocAppError("savePreferences", "api.preference.save_preferences.set.app_error", nil,
+ c.T("api.preference.save_preferences.set_details.app_error",
+ map[string]interface{}{"SessionUserId": c.Session.UserId, "PreferenceUserId": preference.UserId}))
c.Err.StatusCode = http.StatusUnauthorized
return
}