summaryrefslogtreecommitdiffstats
path: root/vendor/gitea.com/macaron/i18n
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-09-10 22:32:58 +0100
committerGitHub <noreply@github.com>2020-09-10 16:32:58 -0500
commitdaefdd1385d12bf0c8321f291dbb6ab242b41c99 (patch)
tree57f4663361f318c12a9ad569d7fdde5d3bf7873c /vendor/gitea.com/macaron/i18n
parent47289344e2ede03b7a74208aad3b92c8bca979c3 (diff)
downloadgitea-daefdd1385d12bf0c8321f291dbb6ab242b41c99.tar.gz
gitea-daefdd1385d12bf0c8321f291dbb6ab242b41c99.zip
Update gitea.com/macaron/i18n (#12806)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'vendor/gitea.com/macaron/i18n')
-rw-r--r--vendor/gitea.com/macaron/i18n/.gitignore1
-rw-r--r--vendor/gitea.com/macaron/i18n/go.mod5
-rw-r--r--vendor/gitea.com/macaron/i18n/go.sum25
-rw-r--r--vendor/gitea.com/macaron/i18n/i18n.go29
4 files changed, 46 insertions, 14 deletions
diff --git a/vendor/gitea.com/macaron/i18n/.gitignore b/vendor/gitea.com/macaron/i18n/.gitignore
new file mode 100644
index 0000000000..a09c56df5c
--- /dev/null
+++ b/vendor/gitea.com/macaron/i18n/.gitignore
@@ -0,0 +1 @@
+/.idea
diff --git a/vendor/gitea.com/macaron/i18n/go.mod b/vendor/gitea.com/macaron/i18n/go.mod
index 03577c6e88..59336d3414 100644
--- a/vendor/gitea.com/macaron/i18n/go.mod
+++ b/vendor/gitea.com/macaron/i18n/go.mod
@@ -3,9 +3,8 @@ module gitea.com/macaron/i18n
go 1.11
require (
- gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb
- github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
- github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e
+ gitea.com/macaron/macaron v1.5.0
+ github.com/stretchr/testify v1.4.0
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6
golang.org/x/text v0.3.2
)
diff --git a/vendor/gitea.com/macaron/i18n/go.sum b/vendor/gitea.com/macaron/i18n/go.sum
index c96916d448..73db18b25b 100644
--- a/vendor/gitea.com/macaron/i18n/go.sum
+++ b/vendor/gitea.com/macaron/i18n/go.sum
@@ -1,21 +1,32 @@
-gitea.com/macaron/inject v0.0.0-20190803172902-8375ba841591 h1:UbCTjPcLrNxR9LzKDjQBMT2zoxZuEnca1pZCpgeMuhQ=
-gitea.com/macaron/inject v0.0.0-20190803172902-8375ba841591/go.mod h1:h6E4kLao1Yko6DOU6QDnQPcuoNzvbZqzj2mtPcEn1aM=
-gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb h1:amL0md6orTj1tXY16ANzVU9FmzQB+W7aJwp8pVDbrmA=
-gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb/go.mod h1:0coI+mSPSwbsyAbOuFllVS38awuk9mevhLD52l50Gjs=
+gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a h1:aOKEXkDTnh4euoH0so/THLXeHtQuqHmDPb1xEk6Ehok=
+gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a/go.mod h1:h6E4kLao1Yko6DOU6QDnQPcuoNzvbZqzj2mtPcEn1aM=
+gitea.com/macaron/macaron v1.5.0 h1:TvWEcHw1/zaHlo0GTuKEukLh3A99+QsU2mjBrXLXjVQ=
+gitea.com/macaron/macaron v1.5.0/go.mod h1:P7hfDbQjcW22lkYkXlxdRIfWOXxH2+K4EogN4Q0UlLY=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
+github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM=
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
+github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
+github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6 h1:sRrkJEHtNoaSvyXMbRgofEOX4/3gMiraevQKJdIBhYE=
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -30,6 +41,12 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.44.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.46.0 h1:VeDZbLYGaupuvIrsYCEOe/L/2Pcs5n7hdO1ZTjporag=
+gopkg.in/ini.v1 v1.46.0 h1:VeDZbLYGaupuvIrsYCEOe/L/2Pcs5n7hdO1ZTjporag=
+gopkg.in/ini.v1 v1.46.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.46.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/gitea.com/macaron/i18n/i18n.go b/vendor/gitea.com/macaron/i18n/i18n.go
index fd114a5bf7..3624aaee53 100644
--- a/vendor/gitea.com/macaron/i18n/i18n.go
+++ b/vendor/gitea.com/macaron/i18n/i18n.go
@@ -12,16 +12,17 @@
// License for the specific language governing permissions and limitations
// under the License.
-// Package i18n is a middleware that provides app Internationalization and Localization of Macaron.
+// Package i18n provides an Internationalization and Localization middleware for Macaron applications.
package i18n
import (
"fmt"
+ "log"
+ "os"
"path"
"strings"
"gitea.com/macaron/macaron"
- "github.com/unknwon/com"
"github.com/unknwon/i18n"
"golang.org/x/text/language"
)
@@ -32,6 +33,16 @@ func Version() string {
return _VERSION
}
+// isFile returns true if given path is a file,
+// or returns false when it's a directory or does not exist.
+func isFile(filePath string) bool {
+ f, e := os.Stat(filePath)
+ if e != nil {
+ return false
+ }
+ return !f.IsDir()
+}
+
// initLocales initializes language type list and Accept-Language header matcher.
func initLocales(opt Options) language.Matcher {
tags := make([]language.Tag, len(opt.Langs))
@@ -41,7 +52,7 @@ func initLocales(opt Options) language.Matcher {
// Append custom locale file.
custom := []interface{}{}
customPath := path.Join(opt.CustomDirectory, fname)
- if com.IsFile(customPath) {
+ if isFile(customPath) {
custom = append(custom, customPath)
}
@@ -54,7 +65,7 @@ func initLocales(opt Options) language.Matcher {
err := i18n.SetMessageWithDesc(lang, opt.Names[i], locale, custom...)
if err != nil && err != i18n.ErrLangAlreadyExist {
- panic(fmt.Errorf("fail to set message file(%s): %v", lang, err))
+ log.Printf("ERROR: failed to set message file(%s) for language %s: %v", lang, opt.Names[i], err)
}
}
return language.NewMatcher(tags)
@@ -98,6 +109,10 @@ type Options struct {
Section string
// Domain used for `lang` cookie. Default is ""
CookieDomain string
+ // Set the Secure flag on the `lang` cookie. Default is disabled.
+ Secure bool
+ // Set the HTTP Only flag on the `lang` cookie. Default is disabled.
+ CookieHttpOnly bool
}
func prepareOptions(options []Options) Options {
@@ -195,7 +210,7 @@ func I18n(options ...Options) macaron.Handler {
// Save language information in cookies.
if !hasCookie {
- ctx.SetCookie("lang", curLang.Lang, 1<<31-1, "/"+strings.TrimPrefix(opt.SubURL, "/"), opt.CookieDomain)
+ ctx.SetCookie("lang", curLang.Lang, 1<<31-1, "/"+strings.TrimPrefix(opt.SubURL, "/"), opt.CookieDomain, opt.Secure, opt.CookieHttpOnly)
}
restLangs := make([]LangType, 0, i18n.Count()-1)
@@ -210,7 +225,7 @@ func I18n(options ...Options) macaron.Handler {
}
// Set language properties.
- locale := Locale{i18n.Locale{lang}}
+ locale := Locale{Locale: i18n.Locale{Lang: lang}}
ctx.Map(locale)
ctx.Locale = locale
ctx.Data[opt.TmplName] = locale
@@ -221,7 +236,7 @@ func I18n(options ...Options) macaron.Handler {
ctx.Data["RestLangs"] = restLangs
if opt.Redirect && isNeedRedir {
- ctx.Redirect(opt.SubURL + ctx.Req.RequestURI[:strings.Index(ctx.Req.RequestURI, "?")])
+ ctx.Redirect(opt.SubURL + path.Clean(ctx.Req.RequestURI[:strings.Index(ctx.Req.RequestURI, "?")]))
}
}
}