From 6fd328ddaa61cd75c24cd2d9b8fdc0f73c7ab974 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 22 Jan 2016 01:37:11 -0300 Subject: Refactoring api to use translations (chunk 2) - Add spanish translations - Does not include tests - Add func to get the translations for a user locale --- api/preference.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'api/preference.go') 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 } -- cgit v1.2.3-1-g7c22