Skip to content

Commit 790541d

Browse files
GustedSysoev, Vladimir
Gusted
authored and
Sysoev, Vladimir
committed
Refactor i18n to locale (go-gitea#20153)
* Refactor `i18n` to `locale` - Currently we're using the `i18n` variable naming for the `locale` struct. This contains locale's specific information and cannot be used for general i18n purpose, therefore refactoring it to `locale` makes more sense. - Ref: go-gitea#20096 (comment) * Update routers/install/install.go
1 parent 9fd6ce8 commit 790541d

File tree

285 files changed

+3668
-3668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+3668
-3668
lines changed

modules/context/context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ func Contexter() func(next http.Handler) http.Handler {
794794
ctx.Data["UnitPullsGlobalDisabled"] = unit.TypePullRequests.UnitGlobalDisabled()
795795
ctx.Data["UnitProjectsGlobalDisabled"] = unit.TypeProjects.UnitGlobalDisabled()
796796

797-
ctx.Data["i18n"] = locale
797+
ctx.Data["locale"] = locale
798798
ctx.Data["AllLangs"] = translation.AllLangs()
799799

800800
next.ServeHTTP(ctx.Resp, ctx.Req)

routers/install/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Init(next http.Handler) http.Handler {
6969
Render: rnd,
7070
Session: session.GetSession(req),
7171
Data: map[string]interface{}{
72-
"i18n": locale,
72+
"locale": locale,
7373
"Title": locale.Tr("install.install"),
7474
"PageIsInstall": true,
7575
"DbTypeNames": dbTypeNames,

routers/install/routes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func installRecovery() func(next http.Handler) http.Handler {
5757
store := dataStore{
5858
"Language": lc.Language(),
5959
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
60-
"i18n": lc,
60+
"locale": lc,
6161
"SignedUserID": int64(0),
6262
"SignedUserName": "",
6363
}

routers/web/base.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func Recovery() func(next http.Handler) http.Handler {
139139
store := dataStore{
140140
"Language": lc.Language(),
141141
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
142-
"i18n": lc,
142+
"locale": lc,
143143
}
144144

145145
user := context.GetContextUser(req)

services/mailer/mail.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, s
8080
"Code": code,
8181
"Language": locale.Language(),
8282
// helper
83-
"i18n": locale,
83+
"locale": locale,
8484
"Str2html": templates.Str2html,
8585
"DotEscape": templates.DotEscape,
8686
}
@@ -131,7 +131,7 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
131131
"Email": email.Email,
132132
"Language": locale.Language(),
133133
// helper
134-
"i18n": locale,
134+
"locale": locale,
135135
"Str2html": templates.Str2html,
136136
"DotEscape": templates.DotEscape,
137137
}
@@ -162,7 +162,7 @@ func SendRegisterNotifyMail(u *user_model.User) {
162162
"Username": u.Name,
163163
"Language": locale.Language(),
164164
// helper
165-
"i18n": locale,
165+
"locale": locale,
166166
"Str2html": templates.Str2html,
167167
"DotEscape": templates.DotEscape,
168168
}
@@ -196,7 +196,7 @@ func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository)
196196
"Link": repo.HTMLURL(),
197197
"Language": locale.Language(),
198198
// helper
199-
"i18n": locale,
199+
"locale": locale,
200200
"Str2html": templates.Str2html,
201201
"DotEscape": templates.DotEscape,
202202
}
@@ -281,7 +281,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
281281
"ReviewComments": reviewComments,
282282
"Language": locale.Language(),
283283
// helper
284-
"i18n": locale,
284+
"locale": locale,
285285
"Str2html": templates.Str2html,
286286
"DotEscape": templates.DotEscape,
287287
}

services/mailer/mail_release.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func mailNewRelease(ctx context.Context, lang string, tos []string, rel *models.
7575
"Subject": subject,
7676
"Language": locale.Language(),
7777
// helper
78-
"i18n": locale,
78+
"locale": locale,
7979
"Str2html": templates.Str2html,
8080
"DotEscape": templates.DotEscape,
8181
}

services/mailer/mail_repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.U
7474
"Language": locale.Language(),
7575
"Destination": destination,
7676
// helper
77-
"i18n": locale,
77+
"locale": locale,
7878
"Str2html": templates.Str2html,
7979
"DotEscape": templates.DotEscape,
8080
}

templates/admin/auth/edit.tmpl

+89-89
Large diffs are not rendered by default.

templates/admin/auth/list.tmpl

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<div class="ui container">
55
{{template "base/alert" .}}
66
<h4 class="ui top attached header">
7-
{{.i18n.Tr "admin.auths.auth_manage_panel"}} ({{.i18n.Tr "admin.total" .Total}})
7+
{{.locale.Tr "admin.auths.auth_manage_panel"}} ({{.locale.Tr "admin.total" .Total}})
88
<div class="ui right">
9-
<a class="ui primary tiny button" href="{{AppSubUrl}}/admin/auths/new">{{.i18n.Tr "admin.auths.new"}}</a>
9+
<a class="ui primary tiny button" href="{{AppSubUrl}}/admin/auths/new">{{.locale.Tr "admin.auths.new"}}</a>
1010
</div>
1111
</h4>
1212
<div class="ui attached table segment">
1313
<table class="ui very basic striped table unstackable">
1414
<thead>
1515
<tr>
1616
<th>ID</th>
17-
<th>{{.i18n.Tr "admin.auths.name"}}</th>
18-
<th>{{.i18n.Tr "admin.auths.type"}}</th>
19-
<th>{{.i18n.Tr "admin.auths.enabled"}}</th>
20-
<th>{{.i18n.Tr "admin.auths.updated"}}</th>
21-
<th>{{.i18n.Tr "admin.users.created"}}</th>
22-
<th>{{.i18n.Tr "admin.users.edit"}}</th>
17+
<th>{{.locale.Tr "admin.auths.name"}}</th>
18+
<th>{{.locale.Tr "admin.auths.type"}}</th>
19+
<th>{{.locale.Tr "admin.auths.enabled"}}</th>
20+
<th>{{.locale.Tr "admin.auths.updated"}}</th>
21+
<th>{{.locale.Tr "admin.users.created"}}</th>
22+
<th>{{.locale.Tr "admin.users.edit"}}</th>
2323
</tr>
2424
</thead>
2525
<tbody>

templates/admin/auth/new.tmpl

+28-28
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<div class="ui container">
55
{{template "base/alert" .}}
66
<h4 class="ui top attached header">
7-
{{.i18n.Tr "admin.auths.new"}}
7+
{{.locale.Tr "admin.auths.new"}}
88
</h4>
99
<div class="ui attached segment">
1010
<form class="ui form" action="{{.Link}}" method="post">
1111
{{template "base/disable_form_autofill"}}
1212
{{.CsrfTokenHtml}}
1313
<!-- Types and name -->
1414
<div class="inline required field {{if .Err_Type}}error{{end}}">
15-
<label>{{.i18n.Tr "admin.auths.auth_type"}}</label>
15+
<label>{{.locale.Tr "admin.auths.auth_type"}}</label>
1616
<div class="ui selection type dropdown">
1717
<input type="hidden" id="auth_type" name="type" value="{{.type}}">
1818
<div class="text">{{.CurrentTypeName}}</div>
@@ -25,7 +25,7 @@
2525
</div>
2626
</div>
2727
<div class="required inline field {{if .Err_Name}}error{{end}}">
28-
<label for="name">{{.i18n.Tr "admin.auths.auth_name"}}</label>
28+
<label for="name">{{.locale.Tr "admin.auths.auth_name"}}</label>
2929
<input id="name" name="name" value="{{.name}}" autofocus required>
3030
</div>
3131

@@ -37,16 +37,16 @@
3737

3838
<!-- PAM -->
3939
<div class="pam required field {{if not (eq .type 4)}}hide{{end}}">
40-
<label for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
40+
<label for="pam_service_name">{{.locale.Tr "admin.auths.pam_service_name"}}</label>
4141
<input id="pam_service_name" name="pam_service_name" value="{{.pam_service_name}}" />
42-
<label for="pam_email_domain">{{.i18n.Tr "admin.auths.pam_email_domain"}}</label>
42+
<label for="pam_email_domain">{{.locale.Tr "admin.auths.pam_email_domain"}}</label>
4343
<input id="pam_email_domain" name="pam_email_domain" value="{{.pam_email_domain}}">
4444
</div>
4545
<div class="pam optional field {{if not (eq .type 4)}}hide{{end}}">
4646
<div class="ui checkbox">
47-
<label for="skip_local_two_fa"><strong>{{.i18n.Tr "admin.auths.skip_local_two_fa"}}</strong></label>
47+
<label for="skip_local_two_fa"><strong>{{.locale.Tr "admin.auths.skip_local_two_fa"}}</strong></label>
4848
<input id="skip_local_two_fa" name="skip_local_two_fa" type="checkbox" {{if .skip_local_two_fa}}checked{{end}}>
49-
<p class="help">{{.i18n.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
49+
<p class="help">{{.locale.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
5050
</div>
5151
</div>
5252

@@ -58,67 +58,67 @@
5858

5959
<div class="ldap field">
6060
<div class="ui checkbox">
61-
<label><strong>{{.i18n.Tr "admin.auths.attributes_in_bind"}}</strong></label>
61+
<label><strong>{{.locale.Tr "admin.auths.attributes_in_bind"}}</strong></label>
6262
<input name="attributes_in_bind" type="checkbox" {{if .attributes_in_bind}}checked{{end}}>
6363
</div>
6464
</div>
6565
<div class="ldap inline field {{if not (eq .type 2)}}hide{{end}}">
6666
<div class="ui checkbox">
67-
<label><strong>{{.i18n.Tr "admin.auths.syncenabled"}}</strong></label>
67+
<label><strong>{{.locale.Tr "admin.auths.syncenabled"}}</strong></label>
6868
<input name="is_sync_enabled" type="checkbox" {{if .is_sync_enabled}}checked{{end}}>
6969
</div>
7070
</div>
7171
<div class="inline field">
7272
<div class="ui checkbox">
73-
<label><strong>{{.i18n.Tr "admin.auths.activated"}}</strong></label>
73+
<label><strong>{{.locale.Tr "admin.auths.activated"}}</strong></label>
7474
<input name="is_active" type="checkbox" {{if .is_active}}checked{{end}}>
7575
</div>
7676
</div>
7777

7878
<div class="field">
79-
<button class="ui green button">{{.i18n.Tr "admin.auths.new"}}</button>
79+
<button class="ui green button">{{.locale.Tr "admin.auths.new"}}</button>
8080
</div>
8181
</form>
8282
</div>
8383

8484
<h4 class="ui top attached header">
85-
{{.i18n.Tr "admin.auths.tips"}}
85+
{{.locale.Tr "admin.auths.tips"}}
8686
</h4>
8787
<div class="ui attached segment">
8888
<h5>GMail Settings:</h5>
8989
<p>Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true</p>
9090

91-
<h5>{{.i18n.Tr "admin.auths.tips.oauth2.general"}}:</h5>
92-
<p>{{.i18n.Tr "admin.auths.tips.oauth2.general.tip"}}</p>
91+
<h5>{{.locale.Tr "admin.auths.tips.oauth2.general"}}:</h5>
92+
<p>{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}</p>
9393

94-
<h5 class="ui top attached header">{{.i18n.Tr "admin.auths.tip.oauth2_provider"}}</h5>
94+
<h5 class="ui top attached header">{{.locale.Tr "admin.auths.tip.oauth2_provider"}}</h5>
9595
<div class="ui attached segment">
9696
<li>Bitbucket</li>
97-
<span>{{.i18n.Tr "admin.auths.tip.bitbucket"}}</span>
97+
<span>{{.locale.Tr "admin.auths.tip.bitbucket"}}</span>
9898
<li>Dropbox</li>
99-
<span>{{.i18n.Tr "admin.auths.tip.dropbox"}}</span>
99+
<span>{{.locale.Tr "admin.auths.tip.dropbox"}}</span>
100100
<li>Facebook</li>
101-
<span>{{.i18n.Tr "admin.auths.tip.facebook"}}</span>
101+
<span>{{.locale.Tr "admin.auths.tip.facebook"}}</span>
102102
<li>GitHub</li>
103-
<span>{{.i18n.Tr "admin.auths.tip.github"}}</span>
103+
<span>{{.locale.Tr "admin.auths.tip.github"}}</span>
104104
<li>GitLab</li>
105-
<span>{{.i18n.Tr "admin.auths.tip.gitlab"}}</span>
105+
<span>{{.locale.Tr "admin.auths.tip.gitlab"}}</span>
106106
<li>Google</li>
107-
<span>{{.i18n.Tr "admin.auths.tip.google_plus"}}</span>
107+
<span>{{.locale.Tr "admin.auths.tip.google_plus"}}</span>
108108
<li>OpenID Connect</li>
109-
<span>{{.i18n.Tr "admin.auths.tip.openid_connect"}}</span>
109+
<span>{{.locale.Tr "admin.auths.tip.openid_connect"}}</span>
110110
<li>Twitter</li>
111-
<span>{{.i18n.Tr "admin.auths.tip.twitter"}}</span>
111+
<span>{{.locale.Tr "admin.auths.tip.twitter"}}</span>
112112
<li>Discord</li>
113-
<span>{{.i18n.Tr "admin.auths.tip.discord"}}</span>
113+
<span>{{.locale.Tr "admin.auths.tip.discord"}}</span>
114114
<li>Gitea</li>
115-
<span>{{.i18n.Tr "admin.auths.tip.gitea"}}</span>
115+
<span>{{.locale.Tr "admin.auths.tip.gitea"}}</span>
116116
<li>Nextcloud</li>
117-
<span>{{.i18n.Tr "admin.auths.tip.nextcloud"}}</span>
117+
<span>{{.locale.Tr "admin.auths.tip.nextcloud"}}</span>
118118
<li>Yandex</li>
119-
<span>{{.i18n.Tr "admin.auths.tip.yandex"}}</span>
119+
<span>{{.locale.Tr "admin.auths.tip.yandex"}}</span>
120120
<li>Mastodon</li>
121-
<span>{{.i18n.Tr "admin.auths.tip.mastodon"}}</span>
121+
<span>{{.locale.Tr "admin.auths.tip.mastodon"}}</span>
122122
</div>
123123
</div>
124124
</div>

0 commit comments

Comments
 (0)