summaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-11-15 05:34:42 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-11-15 11:34:42 +0800
commita6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa (patch)
treeff8c2373a537e415c50a2a2ad3f8a7b1b5e9e17a /vendor/github.com
parentbd23e36becde2fbf109c51ee2abcaa167880a29a (diff)
downloadgitea-a6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa.tar.gz
gitea-a6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa.zip
Update go-ini dependency and remove semicolon hack in translations (#2913)
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/Unknwon/i18n/Makefile12
-rw-r--r--vendor/github.com/Unknwon/i18n/README.md6
-rw-r--r--vendor/github.com/Unknwon/i18n/i18n.go32
3 files changed, 35 insertions, 15 deletions
diff --git a/vendor/github.com/Unknwon/i18n/Makefile b/vendor/github.com/Unknwon/i18n/Makefile
new file mode 100644
index 0000000000..8ff1ac4399
--- /dev/null
+++ b/vendor/github.com/Unknwon/i18n/Makefile
@@ -0,0 +1,12 @@
+.PHONY: build test bench vet
+
+build: vet bench
+
+test:
+ go test -v -cover
+
+bench:
+ go test -v -cover -test.bench=. -test.benchmem
+
+vet:
+ go vet \ No newline at end of file
diff --git a/vendor/github.com/Unknwon/i18n/README.md b/vendor/github.com/Unknwon/i18n/README.md
index cd96c9ade6..7503e41f28 100644
--- a/vendor/github.com/Unknwon/i18n/README.md
+++ b/vendor/github.com/Unknwon/i18n/README.md
@@ -1,4 +1,4 @@
-i18n
+i18n [![GoDoc](https://godoc.org/github.com/Unknwon/i18n?status.svg)](https://godoc.org/github.com/Unknwon/i18n) [![Sourcegraph](https://sourcegraph.com/github.com/Unknwon/i18n/-/badge.svg)](https://sourcegraph.com/github.com/Unknwon/i18n?badge)
====
Package i18n is for app Internationalization and Localization.
@@ -131,4 +131,6 @@ This command can operate 1 or more files in one command.
## More information
-If the key does not exist, then i18n will return the key string to caller. For instance, when key name is `hi` and it does not exist in locale file, simply return `hi` as output.
+- The first locale you load to the module is considered as **default locale**.
+- When matching non-default locale and didn't find the string, i18n will have a second try on default locale.
+- If i18n still cannot find string in the default locale, raw string will be returned. For instance, when the string is `hi` and it does not exist in locale file, simply return `hi` as output.
diff --git a/vendor/github.com/Unknwon/i18n/i18n.go b/vendor/github.com/Unknwon/i18n/i18n.go
index 962fbcf039..38f0899dd3 100644
--- a/vendor/github.com/Unknwon/i18n/i18n.go
+++ b/vendor/github.com/Unknwon/i18n/i18n.go
@@ -156,7 +156,10 @@ func GetDescriptionByLang(lang string) string {
}
func SetMessageWithDesc(lang, langDesc string, localeFile interface{}, otherLocaleFiles ...interface{}) error {
- message, err := ini.Load(localeFile, otherLocaleFiles...)
+ message, err := ini.LoadSources(ini.LoadOptions{
+ IgnoreInlineComment: true,
+ UnescapeValueCommentSymbols: true,
+ }, localeFile, otherLocaleFiles...)
if err == nil {
message.BlockMode = false
lc := new(locale)
@@ -194,10 +197,11 @@ func (l Locale) Index() int {
// Tr translates content to target language.
func Tr(lang, format string, args ...interface{}) string {
var section string
- parts := strings.SplitN(format, ".", 2)
- if len(parts) == 2 {
- section = parts[0]
- format = parts[1]
+
+ idx := strings.IndexByte(format, '.')
+ if idx > 0 {
+ section = format[:idx]
+ format = format[idx+1:]
}
value, ok := locales.Get(lang, section, format)
@@ -208,15 +212,17 @@ func Tr(lang, format string, args ...interface{}) string {
if len(args) > 0 {
params := make([]interface{}, 0, len(args))
for _, arg := range args {
- if arg != nil {
- val := reflect.ValueOf(arg)
- if val.Kind() == reflect.Slice {
- for i := 0; i < val.Len(); i++ {
- params = append(params, val.Index(i).Interface())
- }
- } else {
- params = append(params, arg)
+ if arg == nil {
+ continue
+ }
+
+ val := reflect.ValueOf(arg)
+ if val.Kind() == reflect.Slice {
+ for i := 0; i < val.Len(); i++ {
+ params = append(params, val.Index(i).Interface())
}
+ } else {
+ params = append(params, arg)
}
}
return fmt.Sprintf(format, params...)