From 9911b66aea076347cfb271b12c90bc31e4e5b5f8 Mon Sep 17 00:00:00 2001
From: Clar Fon
Date: Mon, 7 Feb 2022 16:21:02 -0500
Subject: [PATCH 01/18] Be more lenient with label colors (#17752)
Accept 12-bit color specifications.
---
models/issue_label.go | 19 ++++++++++++++++++-
models/issue_label_test.go | 8 ++++++--
services/forms/repo_form.go | 2 +-
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/models/issue_label.go b/models/issue_label.go
index 53d28c0596386..0aea620773791 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -22,7 +22,7 @@ import (
)
// LabelColorPattern is a regexp witch can validate LabelColor
-var LabelColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")
+var LabelColorPattern = regexp.MustCompile("^#?(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$")
// Label represents a label of repository for issues.
type Label struct {
@@ -258,6 +258,23 @@ func NewLabel(label *Label) error {
if !LabelColorPattern.MatchString(label.Color) {
return fmt.Errorf("bad color code: %s", label.Color)
}
+
+ // normalize case
+ label.Color = strings.ToLower(label.Color)
+
+ // add leading hash
+ if label.Color[0] != '#' {
+ label.Color = "#" + label.Color
+ }
+
+ // convert 3-character shorthand into 6-character version
+ if len(label.Color) == 4 {
+ r := label.Color[1]
+ g := label.Color[2]
+ b := label.Color[3]
+ label.Color = fmt.Sprintf("#%c%c%c%c%c%c", r, r, g, g, b, b)
+ }
+
return newLabel(db.GetEngine(db.DefaultContext), label)
}
diff --git a/models/issue_label_test.go b/models/issue_label_test.go
index 887f7f1425fe4..68281dd7ad5f1 100644
--- a/models/issue_label_test.go
+++ b/models/issue_label_test.go
@@ -38,11 +38,15 @@ func TestNewLabels(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
labels := []*Label{
{RepoID: 2, Name: "labelName2", Color: "#123456"},
- {RepoID: 3, Name: "labelName3", Color: "#23456F"},
+ {RepoID: 3, Name: "labelName3", Color: "#123"},
+ {RepoID: 4, Name: "labelName4", Color: "ABCDEF"},
+ {RepoID: 5, Name: "labelName5", Color: "DEF"},
}
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: ""}))
- assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "123456"}))
+ assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "#45G"}))
assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "#12345G"}))
+ assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "45G"}))
+ assert.Error(t, NewLabel(&Label{RepoID: 3, Name: "invalid Color", Color: "12345G"}))
for _, label := range labels {
unittest.AssertNotExistsBean(t, label)
}
diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go
index e6bd088da414b..b32bd3cafd9d3 100644
--- a/services/forms/repo_form.go
+++ b/services/forms/repo_form.go
@@ -549,7 +549,7 @@ type CreateLabelForm struct {
ID int64
Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_title"`
Description string `binding:"MaxSize(200)" locale:"repo.issues.label_description"`
- Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
+ Color string `binding:"Required;MaxSize(7)" locale:"repo.issues.label_color"`
}
// Validate validates the fields
From 99d14f6051854fe0e6dfc7fb6f4eb0a839179977 Mon Sep 17 00:00:00 2001
From: Clar Fon
Date: Mon, 7 Feb 2022 16:56:45 -0500
Subject: [PATCH 02/18] Add separate SSH_USER config option (#17584)
Co-authored-by: zeripath
---
custom/conf/app.example.ini | 7 +++++--
docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 +
integrations/repo_test.go | 2 +-
models/repo/repo.go | 5 +----
models/repo/wiki_test.go | 2 +-
models/unittest/testdb.go | 2 ++
modules/setting/setting.go | 2 ++
7 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index bc98f4ca17ad3..8dac6ab3abc5a 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -82,12 +82,15 @@ RUN_MODE = ; prod
;; Whether to use the builtin SSH server or not.
;START_SSH_SERVER = false
;;
-;; Username to use for the builtin SSH server. If blank, then it is the value of RUN_USER.
-;BUILTIN_SSH_SERVER_USER =
+;; Username to use for the builtin SSH server.
+;BUILTIN_SSH_SERVER_USER = %(RUN_USER)s
;;
;; Domain name to be exposed in clone URL
;SSH_DOMAIN = %(DOMAIN)s
;;
+;; SSH username displayed in clone URLs.
+;SSH_USER = %(BUILTIN_SSH_SERVER_USER)s
+;;
;; The network interface the builtin SSH server should listen on
;SSH_LISTEN_HOST =
;;
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
index d8a3b897cc019..a3999595ab1bb 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -265,6 +265,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
- `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
- `START_SSH_SERVER`: **false**: When enabled, use the built-in SSH server.
- `BUILTIN_SSH_SERVER_USER`: **%(RUN_USER)s**: Username to use for the built-in SSH Server.
+- `SSH_USER`: **%(BUILTIN_SSH_SERVER_USER)**: SSH username displayed in clone URLs. This is only for people who configure the SSH server themselves; in most cases, you want to leave this blank and modify the `BUILTIN_SSH_SERVER_USER`.
- `SSH_DOMAIN`: **%(DOMAIN)s**: Domain name of this server, used for displayed clone URL.
- `SSH_PORT`: **22**: SSH port displayed in clone URL.
- `SSH_LISTEN_HOST`: **0.0.0.0**: Listen address for the built-in SSH server.
diff --git a/integrations/repo_test.go b/integrations/repo_test.go
index 8c4cdf5a969fc..677ba57f8076f 100644
--- a/integrations/repo_test.go
+++ b/integrations/repo_test.go
@@ -135,7 +135,7 @@ func TestViewRepo1CloneLinkAuthorized(t *testing.T) {
assert.Equal(t, setting.AppURL+"user2/repo1.git", link)
link, exists = htmlDoc.doc.Find("#repo-clone-ssh").Attr("data-link")
assert.True(t, exists, "The template has changed")
- sshURL := fmt.Sprintf("ssh://%s@%s:%d/user2/repo1.git", setting.SSH.BuiltinServerUser, setting.SSH.Domain, setting.SSH.Port)
+ sshURL := fmt.Sprintf("ssh://%s@%s:%d/user2/repo1.git", setting.SSH.User, setting.SSH.Domain, setting.SSH.Port)
assert.Equal(t, sshURL, link)
}
diff --git a/models/repo/repo.go b/models/repo/repo.go
index 353d707e60957..28d976773df43 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -540,10 +540,7 @@ func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
repoName += ".wiki"
}
- sshUser := setting.RunUser
- if setting.SSH.StartBuiltinServer {
- sshUser = setting.SSH.BuiltinServerUser
- }
+ sshUser := setting.SSH.User
cl := new(CloneLink)
diff --git a/models/repo/wiki_test.go b/models/repo/wiki_test.go
index 72f5280ce5aeb..f5e61e5ae3eeb 100644
--- a/models/repo/wiki_test.go
+++ b/models/repo/wiki_test.go
@@ -19,7 +19,7 @@ func TestRepository_WikiCloneLink(t *testing.T) {
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
cloneLink := repo.WikiCloneLink()
- assert.Equal(t, "ssh://runuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
+ assert.Equal(t, "ssh://sshuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
}
diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go
index c904646d28151..80dcb428df6ab 100644
--- a/models/unittest/testdb.go
+++ b/models/unittest/testdb.go
@@ -64,6 +64,8 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
setting.AppURL = "https://try.gitea.io/"
setting.RunUser = "runuser"
+ setting.SSH.User = "sshuser"
+ setting.SSH.BuiltinServerUser = "builtinuser"
setting.SSH.Port = 3000
setting.SSH.Domain = "try.gitea.io"
setting.Database.UseSQLite3 = true
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 5b8683f578382..7841fbcdc310f 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -131,6 +131,7 @@ var (
BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
Domain string `ini:"SSH_DOMAIN"`
Port int `ini:"SSH_PORT"`
+ User string `ini:"SSH_USER"`
ListenHost string `ini:"SSH_LISTEN_HOST"`
ListenPort int `ini:"SSH_LISTEN_PORT"`
RootPath string `ini:"SSH_ROOT_PATH"`
@@ -970,6 +971,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
}
SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
+ SSH.User = Cfg.Section("server").Key("SSH_USER").MustString(SSH.BuiltinServerUser)
newRepository()
From 8422b1c55c979d3077614eb9bb027876695f3240 Mon Sep 17 00:00:00 2001
From: GiteaBot
Date: Tue, 8 Feb 2022 00:15:59 +0000
Subject: [PATCH 03/18] [skip ci] Updated translations via Crowdin
---
options/locale/locale_zh-CN.ini | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index 8fc8c30e5cfef..975154597dd37 100644
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -957,14 +957,14 @@ migrate.migrating=正在从 %s 迁移...
migrate.migrating_failed=从 %s 迁移失败。
migrate.migrating_failed.error=错误:%s
migrate.migrating_failed_no_addr=迁移失败。
-migrate.github.description=从 github.com 或其他 GitHub 实例迁移数据。
+migrate.github.description=从 github.com 或其他 GitHub 实例迁移数据
migrate.git.description=从任意 Git 服务迁移仓库。
-migrate.gitlab.description=从 gitlab.com 或其他 GitLab 实例迁移数据。
-migrate.gitea.description=从 gitea.com 或其他 Gitea 实例迁移数据。
+migrate.gitlab.description=从 gitlab.com 或其他 GitLab 实例迁移数据
+migrate.gitea.description=从 gitea.com 或其他 Gitea 实例迁移数据
migrate.gogs.description=从 notabug.org 或其他 Gogs 实例迁移数据。
-migrate.onedev.description=从 code.onedev.io 或其他 OneDev 实例迁移数据。
-migrate.codebase.description=从 codebasehq.com 迁移数据。
-migrate.gitbucket.description=从 GitBucket 实例迁移数据。
+migrate.onedev.description=从 code.onedev.io 或其他 OneDev 实例迁移数据
+migrate.codebase.description=从 codebasehq.com 迁移数据
+migrate.gitbucket.description=从 GitBucket 实例迁移数据
migrate.migrating_git=迁移Git数据
migrate.migrating_topics=迁移主题
migrate.migrating_milestones=迁移里程碑
From 7b25a010c89835e036f1b0cc5af65249bfd2781b Mon Sep 17 00:00:00 2001
From: Gusted
Date: Tue, 8 Feb 2022 02:34:37 +0100
Subject: [PATCH 04/18] Only request write when necessary (#18657)
* Only request write when necessary
- Only request write for `INTERNAL_TOKEN_URI` when no token was found.
- Resolves #18655
* Fix perm
* Update setting.go
* Update setting.go
* Update setting.go
Co-authored-by: wxiaoguang
Co-authored-by: zeripath
---
modules/setting/setting.go | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 7841fbcdc310f..ee2821df07edd 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -8,7 +8,6 @@ package setting
import (
"encoding/base64"
"fmt"
- "io"
"math"
"net"
"net/url"
@@ -1082,28 +1081,22 @@ func loadInternalToken(sec *ini.Section) string {
}
switch tempURI.Scheme {
case "file":
- fp, err := os.OpenFile(tempURI.RequestURI(), os.O_RDWR, 0o600)
- if err != nil {
+ buf, err := os.ReadFile(tempURI.RequestURI())
+ if err != nil && !os.IsNotExist(err) {
log.Fatal("Failed to open InternalTokenURI (%s): %v", uri, err)
}
- defer fp.Close()
-
- buf, err := io.ReadAll(fp)
- if err != nil {
- log.Fatal("Failed to read InternalTokenURI (%s): %v", uri, err)
- }
// No token in the file, generate one and store it.
if len(buf) == 0 {
token, err := generate.NewInternalToken()
if err != nil {
log.Fatal("Error generate internal token: %v", err)
}
- if _, err := io.WriteString(fp, token); err != nil {
+ err = os.WriteFile(tempURI.RequestURI(), []byte(token), 0o600)
+ if err != nil {
log.Fatal("Error writing to InternalTokenURI (%s): %v", uri, err)
}
return token
}
-
return strings.TrimSpace(string(buf))
default:
log.Fatal("Unsupported URI-Scheme %q (INTERNAL_TOKEN_URI = %q)", tempURI.Scheme, uri)
From a60e8be8d15e90a44f2a746a4e8d81a81e03d2db Mon Sep 17 00:00:00 2001
From: wxiaoguang
Date: Tue, 8 Feb 2022 11:02:30 +0800
Subject: [PATCH 05/18] Refactor i18n, use Locale to provide i18n/translation
related functions (#18648)
* remove unnecessary web context data fields, and unify the i18n/translation related functions to `Locale`
* in development, show an error if a translation key is missing
* remove the unnecessary loops `for _, lang := range translation.AllLangs()` for every request, which improves the performance slightly
* use `ctx.Locale.Language()` instead of `ctx.Data["Lang"].(string)`
* add more comments about how the Locale/LangType fields are used
---
modules/context/context.go | 9 -----
modules/translation/translation.go | 38 ++++++++++++++-----
routers/install/install.go | 11 +-----
routers/web/repo/blame.go | 2 +-
routers/web/repo/issue_content_history.go | 10 ++---
templates/admin/process-row.tmpl | 2 +-
templates/base/footer_content.tmpl | 4 +-
templates/base/head.tmpl | 2 +-
templates/repo/activity.tmpl | 12 +++---
templates/repo/commit_page.tmpl | 4 +-
templates/repo/commits_list.tmpl | 4 +-
templates/repo/diff/comments.tmpl | 2 +-
templates/repo/issue/milestone_issues.tmpl | 2 +-
templates/repo/issue/milestones.tmpl | 2 +-
templates/repo/issue/view_content.tmpl | 2 +-
.../repo/issue/view_content/comments.tmpl | 6 +--
templates/repo/issue/view_content/pull.tmpl | 4 +-
templates/repo/issue/view_title.tmpl | 4 +-
templates/repo/projects/list.tmpl | 2 +-
templates/repo/projects/view.tmpl | 2 +-
templates/repo/release/list.tmpl | 4 +-
templates/repo/settings/lfs.tmpl | 2 +-
templates/repo/settings/lfs_file_find.tmpl | 2 +-
templates/repo/settings/lfs_locks.tmpl | 2 +-
templates/repo/view_list.tmpl | 4 +-
templates/repo/wiki/pages.tmpl | 2 +-
templates/repo/wiki/revision.tmpl | 2 +-
templates/repo/wiki/view.tmpl | 2 +-
templates/shared/issuelist.tmpl | 2 +-
templates/user/dashboard/milestones.tmpl | 2 +-
.../user/settings/security/webauthn.tmpl | 2 +-
31 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/modules/context/context.go b/modules/context/context.go
index 887cffdbf992e..7ae37208e47bd 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -38,7 +38,6 @@ import (
"gitea.com/go-chi/session"
chi "github.com/go-chi/chi/v5"
"github.com/unknwon/com"
- "github.com/unknwon/i18n"
"github.com/unrolled/render"
"golang.org/x/crypto/pbkdf2"
)
@@ -738,15 +737,7 @@ func Contexter() func(next http.Handler) http.Handler {
ctx.Data["UnitProjectsGlobalDisabled"] = unit.TypeProjects.UnitGlobalDisabled()
ctx.Data["i18n"] = locale
- ctx.Data["Tr"] = i18n.Tr
- ctx.Data["Lang"] = locale.Language()
ctx.Data["AllLangs"] = translation.AllLangs()
- for _, lang := range translation.AllLangs() {
- if lang.Lang == locale.Language() {
- ctx.Data["LangName"] = lang.Name
- break
- }
- }
next.ServeHTTP(ctx.Resp, ctx.Req)
diff --git a/modules/translation/translation.go b/modules/translation/translation.go
index 977f2cdc233eb..fd38e4d510081 100644
--- a/modules/translation/translation.go
+++ b/modules/translation/translation.go
@@ -25,17 +25,18 @@ type Locale interface {
// LangType represents a lang type
type LangType struct {
- Lang, Name string
+ Lang, Name string // these fields are used directly in templates: {{range .AllLangs}}{{.Lang}}{{.Name}}{{end}}
}
var (
matcher language.Matcher
- allLangs []LangType
+ allLangs []*LangType
+ allLangMap map[string]*LangType
supportedTags []language.Tag
)
// AllLangs returns all supported languages sorted by name
-func AllLangs() []LangType {
+func AllLangs() []*LangType {
return allLangs
}
@@ -81,14 +82,17 @@ func InitLocales() {
}
i18n.SetDefaultLang("en-US")
- allLangs = make([]LangType, 0, i18n.Count()-1)
+ allLangs = make([]*LangType, 0, i18n.Count())
+ allLangMap = map[string]*LangType{}
langs := i18n.ListLangs()
- names := i18n.ListLangDescs()
+ descs := i18n.ListLangDescs()
for i, v := range langs {
- allLangs = append(allLangs, LangType{v, names[i]})
+ l := &LangType{v, descs[i]}
+ allLangs = append(allLangs, l)
+ allLangMap[v] = l
}
- // Sort languages case insensitive according to their name - needed for the user settings
+ // Sort languages case-insensitive according to their name - needed for the user settings
sort.Slice(allLangs, func(i, j int) bool {
return strings.ToLower(allLangs[i].Name) < strings.ToLower(allLangs[j].Name)
})
@@ -102,13 +106,18 @@ func Match(tags ...language.Tag) language.Tag {
// locale represents the information of localization.
type locale struct {
- Lang string
+ Lang, LangName string // these fields are used directly in templates: .i18n.Lang
}
// NewLocale return a locale
func NewLocale(lang string) Locale {
+ langName := "unknown"
+ if l, ok := allLangMap[lang]; ok {
+ langName = l.Name
+ }
return &locale{
- Lang: lang,
+ Lang: lang,
+ LangName: langName,
}
}
@@ -118,7 +127,16 @@ func (l *locale) Language() string {
// Tr translates content to target language.
func (l *locale) Tr(format string, args ...interface{}) string {
- return i18n.Tr(l.Lang, format, args...)
+ if setting.IsProd {
+ return i18n.Tr(l.Lang, format, args...)
+ }
+
+ // in development, we should show an error if a translation key is missing
+ s, ok := TryTr(l.Lang, format, args...)
+ if !ok {
+ log.Error("missing i18n translation key: %q", format)
+ }
+ return s
}
// Language specific rules for translating plural texts
diff --git a/routers/install/install.go b/routers/install/install.go
index eb2cd2346395a..98eeb5f8a0ea7 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -71,25 +71,16 @@ func Init(next http.Handler) http.Handler {
Render: rnd,
Session: session.GetSession(req),
Data: map[string]interface{}{
+ "i18n": locale,
"Title": locale.Tr("install.install"),
"PageIsInstall": true,
"DbTypeNames": getDbTypeNames(),
- "i18n": locale,
- "Language": locale.Language(),
- "Lang": locale.Language(),
"AllLangs": translation.AllLangs(),
- "CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"PageStartTime": startTime,
"PasswordHashAlgorithms": user_model.AvailableHashAlgorithms,
},
}
- for _, lang := range translation.AllLangs() {
- if lang.Lang == locale.Language() {
- ctx.Data["LangName"] = lang.Name
- break
- }
- }
ctx.Req = context.WithContext(req, &ctx)
next.ServeHTTP(resp, ctx.Req)
})
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index 588e432e3aadb..e96e2142d295a 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -255,7 +255,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
commitCnt++
// User avatar image
- commitSince := timeutil.TimeSinceUnix(timeutil.TimeStamp(commit.Author.When.Unix()), ctx.Data["Lang"].(string))
+ commitSince := timeutil.TimeSinceUnix(timeutil.TimeStamp(commit.Author.When.Unix()), ctx.Locale.Language())
var avatar string
if commit.User != nil {
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go
index 75951ca25b9f1..5b5aced6ec08c 100644
--- a/routers/web/repo/issue_content_history.go
+++ b/routers/web/repo/issue_content_history.go
@@ -29,7 +29,7 @@ func GetContentHistoryOverview(ctx *context.Context) {
return
}
- lang := ctx.Data["Lang"].(string)
+ lang := ctx.Locale.Language()
editedHistoryCountMap, _ := issuesModel.QueryIssueContentHistoryEditedCountMap(db.DefaultContext, issue.ID)
ctx.JSON(http.StatusOK, map[string]interface{}{
"i18n": map[string]interface{}{
@@ -55,17 +55,17 @@ func GetContentHistoryList(ctx *context.Context) {
// render history list to HTML for frontend dropdown items: (name, value)
// name is HTML of "avatar + userName + userAction + timeSince"
// value is historyId
- lang := ctx.Data["Lang"].(string)
+ lang := ctx.Locale.Language()
var results []map[string]interface{}
for _, item := range items {
var actionText string
if item.IsDeleted {
- actionTextDeleted := i18n.Tr(lang, "repo.issues.content_history.deleted")
+ actionTextDeleted := ctx.Locale.Tr("repo.issues.content_history.deleted")
actionText = "" + actionTextDeleted + ""
} else if item.IsFirstCreated {
- actionText = i18n.Tr(lang, "repo.issues.content_history.created")
+ actionText = ctx.Locale.Tr("repo.issues.content_history.created")
} else {
- actionText = i18n.Tr(lang, "repo.issues.content_history.edited")
+ actionText = ctx.Locale.Tr("repo.issues.content_history.edited")
}
timeSinceText := timeutil.TimeSinceUnix(item.EditedUnix, lang)
results = append(results, map[string]interface{}{
diff --git a/templates/admin/process-row.tmpl b/templates/admin/process-row.tmpl
index 814727e7fae0d..146ecc7b29b0f 100644
--- a/templates/admin/process-row.tmpl
+++ b/templates/admin/process-row.tmpl
@@ -2,7 +2,7 @@
-
{{TimeSince .Process.Start .root.Lang}}
+
{{TimeSince .Process.Start .root.i18n.Lang}}
{{svg "octicon-trash" 16 "text-red"}}
diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl
index e30fe70768632..979c03146cdc5 100644
--- a/templates/base/footer_content.tmpl
+++ b/templates/base/footer_content.tmpl
@@ -9,10 +9,10 @@
{{end}}
{{svg "octicon-globe"}}
-
{{.LangName}}
+
{{.i18n.LangName}}
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index 3068dd4cbbe13..32e206a95d58e 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -1,5 +1,5 @@
-
+
diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl
index 3086ca8e8d3ce..36108dddcb789 100644
--- a/templates/repo/activity.tmpl
+++ b/templates/repo/activity.tmpl
@@ -131,7 +131,7 @@
{{if not .IsTag}}
{{.Title | RenderEmoji}}
{{end}}
- {{TimeSinceUnix .CreatedUnix $.Lang}}
+ {{TimeSinceUnix .CreatedUnix $.i18n.Lang}}
{{end}}
@@ -150,7 +150,7 @@
{{$.i18n.Tr "repo.activity.merged_prs_label"}}
#{{.Index}} {{.Issue.Title | RenderEmoji}}
- {{TimeSinceUnix .MergedUnix $.Lang}}
+ {{TimeSinceUnix .MergedUnix $.i18n.Lang}}
{{end}}
@@ -169,7 +169,7 @@
{{$.i18n.Tr "repo.activity.opened_prs_label"}}
#{{.Index}} {{.Issue.Title | RenderEmoji}}
- {{TimeSinceUnix .Issue.CreatedUnix $.Lang}}
+ {{TimeSinceUnix .Issue.CreatedUnix $.i18n.Lang}}
{{end}}
@@ -188,7 +188,7 @@
{{$.i18n.Tr "repo.activity.closed_issue_label"}}
#{{.Index}} {{.Title | RenderEmoji}}
- {{TimeSinceUnix .ClosedUnix $.Lang}}
+ {{TimeSinceUnix .ClosedUnix $.i18n.Lang}}
{{end}}
@@ -207,7 +207,7 @@
{{$.i18n.Tr "repo.activity.new_issue_label"}}
#{{.Index}} {{.Title | RenderEmoji}}
- {{TimeSinceUnix .CreatedUnix $.Lang}}
+ {{TimeSinceUnix .CreatedUnix $.i18n.Lang}}
{{end}}
@@ -231,7 +231,7 @@
{{else}}
{{.Title | RenderEmoji}}
{{end}}
- {{TimeSinceUnix .UpdatedUnix $.Lang}}
+ {{TimeSinceUnix .UpdatedUnix $.i18n.Lang}}
{{end}}
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl
index 931201fed60f1..331c439c0218f 100644
--- a/templates/repo/commit_page.tmpl
+++ b/templates/repo/commit_page.tmpl
@@ -47,7 +47,7 @@
{{avatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "mr-3"}}
{{.Commit.Author.Name}}
{{end}}
- {{TimeSince .Commit.Author.When $.Lang}}
+ {{TimeSince .Commit.Author.When $.i18n.Lang}}
{{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
{{.i18n.Tr "repo.diff.committed_by"}}
{{if ne .Verification.CommittingUser.ID 0}}
@@ -169,7 +169,7 @@
{{else}}
{{.NoteCommit.Author.Name}}
{{end}}
- {{TimeSince .NoteCommit.Author.When $.Lang}}
+ {{TimeSince .NoteCommit.Author.When $.i18n.Lang}}
{{RenderNote $.Context .Note $.RepoLink $.Repository.ComposeMetas}}
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl
index e8ac4020f44e0..86ad8352021a0 100644
--- a/templates/repo/commits_list.tmpl
+++ b/templates/repo/commits_list.tmpl
@@ -76,9 +76,9 @@
{{end}}
{{if .Committer}}
-
{{TimeSince .Committer.When $.Lang}} |
+
{{TimeSince .Committer.When $.i18n.Lang}} |
{{else}}
-
{{TimeSince .Author.When $.Lang}} |
+
{{TimeSince .Author.When $.i18n.Lang}} |
{{end}}
{{end}}
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index 9ec42a8d119b7..3b8f1c2a9c59d 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -1,6 +1,6 @@
{{range .comments}}
-{{ $createdStr:= TimeSinceUnix .CreatedUnix $.root.Lang }}
+{{ $createdStr:= TimeSinceUnix .CreatedUnix $.root.i18n.Lang }}
- {{ $closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix $.Lang }}
+ {{ $closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix $.i18n.Lang }}
{{if .IsClosed}}
{{svg "octicon-clock"}} {{$.i18n.Tr "repo.milestones.closed" $closedDate|Str2html}}
{{else}}
diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl
index 448d758e3ebfd..dc168bdc1a7df 100644
--- a/templates/repo/issue/milestones.tmpl
+++ b/templates/repo/issue/milestones.tmpl
@@ -68,7 +68,7 @@