Finish the first step of i18n.

This commit is contained in:
zicla
2019-05-04 19:20:09 +08:00
parent 2b687331b5
commit 900924d196
19 changed files with 270 additions and 209 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"github.com/eyebluecn/tank/code/core"
"github.com/eyebluecn/tank/code/tool/i18n"
"github.com/eyebluecn/tank/code/tool/result"
"github.com/eyebluecn/tank/code/tool/util"
"io/ioutil"
@ -84,10 +85,10 @@ func (this *DavController) CheckCurrentUser(writer http.ResponseWriter, request
user := this.userDao.FindByUsername(username)
if user == nil {
panic(result.BadRequest("用户名或密码错误"))
panic(result.BadRequestI18n(request, i18n.UsernameOrPasswordError))
} else {
if !util.MatchBcrypt(password, user.Password) {
panic(result.BadRequest("用户名或密码错误"))
panic(result.BadRequestI18n(request, i18n.UsernameOrPasswordError))
}
}
@ -108,7 +109,7 @@ func (this *DavController) HandleRoutes(writer http.ResponseWriter, request *htt
path := request.URL.Path
//匹配 /api/dav{subPath}
pattern := fmt.Sprintf(`^%s(.*)$`, WEBDAV_PREFFIX)
pattern := fmt.Sprintf(`^%s(.*)$`, WEBDAV_PREFIX)
reg := regexp.MustCompile(pattern)
strs := reg.FindStringSubmatch(path)
if len(strs) == 2 {