summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-01-19 22:00:01 -0600
committer=Corey Hulen <corey@hulen.com>2016-01-19 22:00:01 -0600
commit8e404c1dcf820cf767e9d6899e8c1efc7bb5ca96 (patch)
treeed96e0aff323aaf7a45d38896ea6a929dc320500 /model
parent36c5c46e24f745ee80b49f47363217fcb740ce53 (diff)
downloadchat-8e404c1dcf820cf767e9d6899e8c1efc7bb5ca96.tar.gz
chat-8e404c1dcf820cf767e9d6899e8c1efc7bb5ca96.tar.bz2
chat-8e404c1dcf820cf767e9d6899e8c1efc7bb5ca96.zip
PLT-7 Adding translation function to context
Diffstat (limited to 'model')
-rw-r--r--model/user.go11
-rw-r--r--model/version.go2
2 files changed, 11 insertions, 2 deletions
diff --git a/model/user.go b/model/user.go
index 4ba35c6c4..7744b0073 100644
--- a/model/user.go
+++ b/model/user.go
@@ -6,11 +6,12 @@ package model
import (
"encoding/json"
"fmt"
- "golang.org/x/crypto/bcrypt"
"io"
"regexp"
"strings"
"unicode/utf8"
+
+ "golang.org/x/crypto/bcrypt"
)
const (
@@ -24,6 +25,7 @@ const (
USER_NOTIFY_ALL = "all"
USER_NOTIFY_MENTION = "mention"
USER_NOTIFY_NONE = "none"
+ DEFAULT_LOCALE = "en"
)
type User struct {
@@ -51,6 +53,7 @@ type User struct {
LastPasswordUpdate int64 `json:"last_password_update,omitempty"`
LastPictureUpdate int64 `json:"last_picture_update,omitempty"`
FailedAttempts int `json:"failed_attempts,omitempty"`
+ Locale string `json:"locale"`
}
// IsValid validates the user and returns an error if it isn't configured
@@ -130,12 +133,17 @@ func (u *User) PreSave() {
u.Username = strings.ToLower(u.Username)
u.Email = strings.ToLower(u.Email)
+ u.Locale = strings.ToLower(u.Locale)
u.CreateAt = GetMillis()
u.UpdateAt = u.CreateAt
u.LastPasswordUpdate = u.CreateAt
+ if u.Locale == "" {
+ u.Locale = DEFAULT_LOCALE
+ }
+
if u.Props == nil {
u.Props = make(map[string]string)
}
@@ -153,6 +161,7 @@ func (u *User) PreSave() {
func (u *User) PreUpdate() {
u.Username = strings.ToLower(u.Username)
u.Email = strings.ToLower(u.Email)
+ u.Locale = strings.ToLower(u.Locale)
u.UpdateAt = GetMillis()
if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
diff --git a/model/version.go b/model/version.go
index 88334ceea..f503ddb84 100644
--- a/model/version.go
+++ b/model/version.go
@@ -28,7 +28,7 @@ var CurrentVersion string = versions[0]
var BuildNumber = "_BUILD_NUMBER_"
var BuildDate = "_BUILD_DATE_"
var BuildHash = "_BUILD_HASH_"
-var BuildEnterpriseReady = "_BUILD_ENTERPRISE_READY_"
+var BuildEnterpriseReady = "false"
func SplitVersion(version string) (int64, int64, int64) {
parts := strings.Split(version, ".")