Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor i18n to locale #20153

Merged
merged 5 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func Contexter() func(next http.Handler) http.Handler {
ctx.Data["UnitPullsGlobalDisabled"] = unit.TypePullRequests.UnitGlobalDisabled()
ctx.Data["UnitProjectsGlobalDisabled"] = unit.TypeProjects.UnitGlobalDisabled()

ctx.Data["i18n"] = locale
ctx.Data["locale"] = locale
ctx.Data["AllLangs"] = translation.AllLangs()

next.ServeHTTP(ctx.Resp, ctx.Req)
Expand Down
2 changes: 1 addition & 1 deletion routers/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func Init(next http.Handler) http.Handler {
Render: rnd,
Session: session.GetSession(req),
Data: map[string]interface{}{
"i18n": locale,
"locale": locale,
"Title": locale.Tr("install.install"),
"PageIsInstall": true,
"DbTypeNames": dbTypeNames,
Expand Down
2 changes: 1 addition & 1 deletion routers/install/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func installRecovery() func(next http.Handler) http.Handler {
store := dataStore{
"Language": lc.Language(),
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"i18n": lc,
"locale": lc,
"SignedUserID": int64(0),
"SignedUserName": "",
}
Expand Down
2 changes: 1 addition & 1 deletion routers/web/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func Recovery() func(next http.Handler) http.Handler {
store := dataStore{
"Language": lc.Language(),
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"i18n": lc,
"locale": lc,
}

user := context.GetContextUser(req)
Expand Down
10 changes: 5 additions & 5 deletions services/mailer/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, s
"Code": code,
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
"Email": email.Email,
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func SendRegisterNotifyMail(u *user_model.User) {
"Username": u.Name,
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository)
"Link": repo.HTMLURL(),
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down Expand Up @@ -281,7 +281,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
"ReviewComments": reviewComments,
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down
2 changes: 1 addition & 1 deletion services/mailer/mail_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func mailNewRelease(ctx context.Context, lang string, tos []string, rel *models.
"Subject": subject,
"Language": locale.Language(),
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down
2 changes: 1 addition & 1 deletion services/mailer/mail_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.U
"Language": locale.Language(),
"Destination": destination,
// helper
"i18n": locale,
"locale": locale,
"Str2html": templates.Str2html,
"DotEscape": templates.DotEscape,
}
Expand Down
178 changes: 89 additions & 89 deletions templates/admin/auth/edit.tmpl

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions templates/admin/auth/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "admin.auths.auth_manage_panel"}} ({{.i18n.Tr "admin.total" .Total}})
{{.locale.Tr "admin.auths.auth_manage_panel"}} ({{.locale.Tr "admin.total" .Total}})
<div class="ui right">
<a class="ui primary tiny button" href="{{AppSubUrl}}/admin/auths/new">{{.i18n.Tr "admin.auths.new"}}</a>
<a class="ui primary tiny button" href="{{AppSubUrl}}/admin/auths/new">{{.locale.Tr "admin.auths.new"}}</a>
</div>
</h4>
<div class="ui attached table segment">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th>ID</th>
<th>{{.i18n.Tr "admin.auths.name"}}</th>
<th>{{.i18n.Tr "admin.auths.type"}}</th>
<th>{{.i18n.Tr "admin.auths.enabled"}}</th>
<th>{{.i18n.Tr "admin.auths.updated"}}</th>
<th>{{.i18n.Tr "admin.users.created"}}</th>
<th>{{.i18n.Tr "admin.users.edit"}}</th>
<th>{{.locale.Tr "admin.auths.name"}}</th>
<th>{{.locale.Tr "admin.auths.type"}}</th>
<th>{{.locale.Tr "admin.auths.enabled"}}</th>
<th>{{.locale.Tr "admin.auths.updated"}}</th>
<th>{{.locale.Tr "admin.users.created"}}</th>
<th>{{.locale.Tr "admin.users.edit"}}</th>
</tr>
</thead>
<tbody>
Expand Down
56 changes: 28 additions & 28 deletions templates/admin/auth/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "admin.auths.new"}}
{{.locale.Tr "admin.auths.new"}}
</h4>
<div class="ui attached segment">
<form class="ui form" action="{{.Link}}" method="post">
{{template "base/disable_form_autofill"}}
{{.CsrfTokenHtml}}
<!-- Types and name -->
<div class="inline required field {{if .Err_Type}}error{{end}}">
<label>{{.i18n.Tr "admin.auths.auth_type"}}</label>
<label>{{.locale.Tr "admin.auths.auth_type"}}</label>
<div class="ui selection type dropdown">
<input type="hidden" id="auth_type" name="type" value="{{.type}}">
<div class="text">{{.CurrentTypeName}}</div>
Expand All @@ -25,7 +25,7 @@
</div>
</div>
<div class="required inline field {{if .Err_Name}}error{{end}}">
<label for="name">{{.i18n.Tr "admin.auths.auth_name"}}</label>
<label for="name">{{.locale.Tr "admin.auths.auth_name"}}</label>
<input id="name" name="name" value="{{.name}}" autofocus required>
</div>

Expand All @@ -37,16 +37,16 @@

<!-- PAM -->
<div class="pam required field {{if not (eq .type 4)}}hide{{end}}">
<label for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
<label for="pam_service_name">{{.locale.Tr "admin.auths.pam_service_name"}}</label>
<input id="pam_service_name" name="pam_service_name" value="{{.pam_service_name}}" />
<label for="pam_email_domain">{{.i18n.Tr "admin.auths.pam_email_domain"}}</label>
<label for="pam_email_domain">{{.locale.Tr "admin.auths.pam_email_domain"}}</label>
<input id="pam_email_domain" name="pam_email_domain" value="{{.pam_email_domain}}">
</div>
<div class="pam optional field {{if not (eq .type 4)}}hide{{end}}">
<div class="ui checkbox">
<label for="skip_local_two_fa"><strong>{{.i18n.Tr "admin.auths.skip_local_two_fa"}}</strong></label>
<label for="skip_local_two_fa"><strong>{{.locale.Tr "admin.auths.skip_local_two_fa"}}</strong></label>
<input id="skip_local_two_fa" name="skip_local_two_fa" type="checkbox" {{if .skip_local_two_fa}}checked{{end}}>
<p class="help">{{.i18n.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
<p class="help">{{.locale.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
</div>
</div>

Expand All @@ -58,67 +58,67 @@

<div class="ldap field">
<div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.auths.attributes_in_bind"}}</strong></label>
<label><strong>{{.locale.Tr "admin.auths.attributes_in_bind"}}</strong></label>
<input name="attributes_in_bind" type="checkbox" {{if .attributes_in_bind}}checked{{end}}>
</div>
</div>
<div class="ldap inline field {{if not (eq .type 2)}}hide{{end}}">
<div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.auths.syncenabled"}}</strong></label>
<label><strong>{{.locale.Tr "admin.auths.syncenabled"}}</strong></label>
<input name="is_sync_enabled" type="checkbox" {{if .is_sync_enabled}}checked{{end}}>
</div>
</div>
<div class="inline field">
<div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.auths.activated"}}</strong></label>
<label><strong>{{.locale.Tr "admin.auths.activated"}}</strong></label>
<input name="is_active" type="checkbox" {{if .is_active}}checked{{end}}>
</div>
</div>

<div class="field">
<button class="ui green button">{{.i18n.Tr "admin.auths.new"}}</button>
<button class="ui green button">{{.locale.Tr "admin.auths.new"}}</button>
</div>
</form>
</div>

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

<h5>{{.i18n.Tr "admin.auths.tips.oauth2.general"}}:</h5>
<p>{{.i18n.Tr "admin.auths.tips.oauth2.general.tip"}}</p>
<h5>{{.locale.Tr "admin.auths.tips.oauth2.general"}}:</h5>
<p>{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}</p>

<h5 class="ui top attached header">{{.i18n.Tr "admin.auths.tip.oauth2_provider"}}</h5>
<h5 class="ui top attached header">{{.locale.Tr "admin.auths.tip.oauth2_provider"}}</h5>
<div class="ui attached segment">
<li>Bitbucket</li>
<span>{{.i18n.Tr "admin.auths.tip.bitbucket"}}</span>
<span>{{.locale.Tr "admin.auths.tip.bitbucket"}}</span>
<li>Dropbox</li>
<span>{{.i18n.Tr "admin.auths.tip.dropbox"}}</span>
<span>{{.locale.Tr "admin.auths.tip.dropbox"}}</span>
<li>Facebook</li>
<span>{{.i18n.Tr "admin.auths.tip.facebook"}}</span>
<span>{{.locale.Tr "admin.auths.tip.facebook"}}</span>
<li>GitHub</li>
<span>{{.i18n.Tr "admin.auths.tip.github"}}</span>
<span>{{.locale.Tr "admin.auths.tip.github"}}</span>
<li>GitLab</li>
<span>{{.i18n.Tr "admin.auths.tip.gitlab"}}</span>
<span>{{.locale.Tr "admin.auths.tip.gitlab"}}</span>
<li>Google</li>
<span>{{.i18n.Tr "admin.auths.tip.google_plus"}}</span>
<span>{{.locale.Tr "admin.auths.tip.google_plus"}}</span>
<li>OpenID Connect</li>
<span>{{.i18n.Tr "admin.auths.tip.openid_connect"}}</span>
<span>{{.locale.Tr "admin.auths.tip.openid_connect"}}</span>
<li>Twitter</li>
<span>{{.i18n.Tr "admin.auths.tip.twitter"}}</span>
<span>{{.locale.Tr "admin.auths.tip.twitter"}}</span>
<li>Discord</li>
<span>{{.i18n.Tr "admin.auths.tip.discord"}}</span>
<span>{{.locale.Tr "admin.auths.tip.discord"}}</span>
<li>Gitea</li>
<span>{{.i18n.Tr "admin.auths.tip.gitea"}}</span>
<span>{{.locale.Tr "admin.auths.tip.gitea"}}</span>
<li>Nextcloud</li>
<span>{{.i18n.Tr "admin.auths.tip.nextcloud"}}</span>
<span>{{.locale.Tr "admin.auths.tip.nextcloud"}}</span>
<li>Yandex</li>
<span>{{.i18n.Tr "admin.auths.tip.yandex"}}</span>
<span>{{.locale.Tr "admin.auths.tip.yandex"}}</span>
<li>Mastodon</li>
<span>{{.i18n.Tr "admin.auths.tip.mastodon"}}</span>
<span>{{.locale.Tr "admin.auths.tip.mastodon"}}</span>
</div>
</div>
</div>
Expand Down
Loading