From 6ae9c97be8ade6a5758434f33b8cb5a66ae525d3 Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Thu, 4 Jun 2026 18:51:56 +0800 Subject: [PATCH] style(aurora): CSS class-based refactor, full i18n, and locale alignment themes/aurora/ (all 11 tmpl templates): - Extract all reusable inline styles to CSS classes in - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

{{.locale.Tr "mail.hi_user_x" .Invite.Email}}

-

{{.locale.Tr "mail.team_invite.text_1" (DotEscape .Inviter.DisplayName) (DotEscape .Team.Name) (DotEscape .Organization.DisplayName)}}

-

{{.locale.Tr "mail.team_invite.text_2"}}

-
- -
- Accept Invitation -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.InviteURL}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/actions/workflow_run.tmpl b/themes/aurora/mail/repo/actions/workflow_run.tmpl index 085f91e..51f388f 100644 --- a/themes/aurora/mail/repo/actions/workflow_run.tmpl +++ b/themes/aurora/mail/repo/actions/workflow_run.tmpl @@ -4,51 +4,139 @@ - {{.Subject}} + + + {{.Subject}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

-

{{.Repo.FullName}} - {{.Run.WorkflowID}}: {{.RunStatusText}}

-

-
- -
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Run.HTMLURL}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/collaborator.tmpl b/themes/aurora/mail/repo/collaborator.tmpl index 8268048..0442858 100644 --- a/themes/aurora/mail/repo/collaborator.tmpl +++ b/themes/aurora/mail/repo/collaborator.tmpl @@ -4,51 +4,132 @@ - {{.Subject}} + + + {{.Subject}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

-

{{.locale.Tr "mail.repo.collaborator.added.text"}} {{.RepoName}}.

-

-
- -
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Link}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/issue/assigned.tmpl b/themes/aurora/mail/repo/issue/assigned.tmpl index 6796e2f..d25176c 100644 --- a/themes/aurora/mail/repo/issue/assigned.tmpl +++ b/themes/aurora/mail/repo/issue/assigned.tmpl @@ -4,51 +4,138 @@ - {{.Subject}} + + + {{.Subject}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

-

{{$repo_url := HTMLFormat "%s" .Issue.Repo.HTMLURL .Issue.Repo.FullName}}{{$link := HTMLFormat "#%d" .Link .Issue.Index}}{{if .IsPull}}{{.locale.Tr "mail.issue_assigned.pull" .Doer.Name $link $repo_url}}{{else}}{{.locale.Tr "mail.issue_assigned.issue" .Doer.Name $link $repo_url}}{{end}}

-

-
- -
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Link}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/issue/default.tmpl b/themes/aurora/mail/repo/issue/default.tmpl index 195ae73..6e5694b 100644 --- a/themes/aurora/mail/repo/issue/default.tmpl +++ b/themes/aurora/mail/repo/issue/default.tmpl @@ -4,60 +4,207 @@ - {{.Subject}} + + + {{.Subject}} + + - -
- - - - - - - - - - + +
+
- logo - {{AppName}} -
-

-

{{if .IsMention}}

{{.locale.Tr "mail.issue.x_mentioned_you" .Doer.Name}}

{{end}}{{if eq .ActionName "push"}}

{{if .Comment.IsForcePush}}{{$oldCommitUrl := printf "%s/commit/%s" .Comment.Issue.PullRequest.BaseRepo.HTMLURL .Comment.OldCommit}}{{$oldShortSha := ShortSha .Comment.OldCommit}}{{$oldCommitLink := HTMLFormat "%[2]s" $oldCommitUrl $oldShortSha}}{{$newCommitUrl := printf "%s/commit/%s" .Comment.Issue.PullRequest.BaseRepo.HTMLURL .Comment.NewCommit}}{{$newShortSha := ShortSha .Comment.NewCommit}}{{$newCommitLink := HTMLFormat "%[2]s" $newCommitUrl $newShortSha}}{{.locale.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink}}{{else}}{{.locale.TrN (len .Comment.Commits) "mail.issue.action.push_1" "mail.issue.action.push_n" .Doer.Name .Comment.Issue.PullRequest.HeadBranch (len .Comment.Commits)}}{{end}}

{{end}}

{{if eq .ActionName "close"}}{{.locale.Tr "mail.issue.action.close" .Doer.Name .Issue.Index}}{{else if eq .ActionName "reopen"}}{{.locale.Tr "mail.issue.action.reopen" .Doer.Name .Issue.Index}}{{else if eq .ActionName "merge"}}{{.locale.Tr "mail.issue.action.merge" .Doer.Name .Issue.Index .Issue.PullRequest.BaseBranch}}{{else if eq .ActionName "approve"}}{{.locale.Tr "mail.issue.action.approve" .Doer.Name}}{{else if eq .ActionName "reject"}}{{.locale.Tr "mail.issue.action.reject" .Doer.Name}}{{else if eq .ActionName "review"}}{{.locale.Tr "mail.issue.action.review" .Doer.Name}}{{else if eq .ActionName "review_dismissed"}}{{.locale.Tr "mail.issue.action.review_dismissed" .Doer.Name .Comment.Review.Reviewer.Name}}{{else if eq .ActionName "ready_for_review"}}{{.locale.Tr "mail.issue.action.ready_for_review" .Doer.Name}}{{end}}{{- if eq .Body ""}}{{if eq .ActionName "new"}}{{.locale.Tr "mail.issue.action.new" .Doer.Name .Issue.Index}}{{end}}{{else}}{{.Body}}{{end -}}{{if .CanReply}} {{.locale.Tr "mail.reply"}}{{end}}

{{- range .ReviewComments}}

{{$.locale.Tr "mail.issue.in_tree_path" .TreePath}}

{{.Patch}}
{{.RenderedContent}}
{{end -}}{{if eq .ActionName "push"}}{{end}}

-

-
-
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Link}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/release.tmpl b/themes/aurora/mail/repo/release.tmpl index a557701..045b48c 100644 --- a/themes/aurora/mail/repo/release.tmpl +++ b/themes/aurora/mail/repo/release.tmpl @@ -4,63 +4,164 @@ - {{.Subject}} + + + {{.Subject}} + + - -
- - - - - - - - - - + +
+
- logo - {{AppName}} -
-

-

{{$release_url := HTMLFormat "%s" .Release.HTMLURL .Release.TagName}}{{$repo_url := HTMLFormat "%s" .Release.Repo.HTMLURL .Release.Repo.FullName}}{{.locale.Tr "mail.release.new.text" .Release.Publisher.Name $release_url $repo_url}} -

{{.locale.Tr "mail.release.title" .Release.Title}}

- {{if .Release.RenderedNote}}

{{.locale.Tr "mail.release.note"}}

{{.Release.RenderedNote}}
{{end}} -

{{.locale.Tr "mail.release.downloads"}}

-

-

-
-
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Link}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/repo/transfer.tmpl b/themes/aurora/mail/repo/transfer.tmpl index 98dbb08..76a178c 100644 --- a/themes/aurora/mail/repo/transfer.tmpl +++ b/themes/aurora/mail/repo/transfer.tmpl @@ -4,51 +4,133 @@ - {{.Subject}} + + + {{.Subject}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

-

{{$url := HTMLFormat "%[2]s" .Link .Repo}}{{.Subject}}. {{.locale.Tr "mail.repo.transfer.body" $url}}

-

-
- -
- {{.locale.Tr "mail.view_it_on" AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{.Link}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/user/auth/activate.tmpl b/themes/aurora/mail/user/auth/activate.tmpl index 6c0a179..4484ec6 100644 --- a/themes/aurora/mail/user/auth/activate.tmpl +++ b/themes/aurora/mail/user/auth/activate.tmpl @@ -4,50 +4,137 @@ - {{.locale.Tr "mail.activate_account.title" (.DisplayName|DotEscape)}} + + + {{.locale.Tr "mail.activate_account.title" (.DisplayName|DotEscape)}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}

-

{{.locale.Tr "mail.activate_account.text_1" (.DisplayName|DotEscape) AppName}}

-

{{.locale.Tr "mail.activate_account.text_2" .ActiveCodeLives}}

-
- {{$activate_url := printf "%suser/activate?code=%s" AppUrl (QueryEscape .Code)}} -
- Activate Account -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{$activate_url}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/themes/aurora/mail/user/auth/activate_email.tmpl b/themes/aurora/mail/user/auth/activate_email.tmpl index 3db02ea..ec48e49 100644 --- a/themes/aurora/mail/user/auth/activate_email.tmpl +++ b/themes/aurora/mail/user/auth/activate_email.tmpl @@ -4,50 +4,135 @@ - {{.locale.Tr "mail.activate_email.title" (.DisplayName|DotEscape)}} + + + {{.locale.Tr "mail.activate_email.title" (.DisplayName|DotEscape)}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}

-

{{.locale.Tr "mail.activate_email.text" .ActiveCodeLives}}

-

-
- {{$activate_url := printf "%suser/activate_email?code=%s&email=%s" AppUrl (QueryEscape .Code) (QueryEscape .Email)}} -
- Verify Email Address -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{$activate_url}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/themes/aurora/mail/user/auth/register_notify.tmpl b/themes/aurora/mail/user/auth/register_notify.tmpl index a61ea00..2048798 100644 --- a/themes/aurora/mail/user/auth/register_notify.tmpl +++ b/themes/aurora/mail/user/auth/register_notify.tmpl @@ -4,53 +4,138 @@ - {{.locale.Tr "mail.register_notify.title" (.DisplayName|DotEscape) AppName}} + + + {{.locale.Tr "mail.register_notify.title" (.DisplayName|DotEscape) AppName}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}

-

{{.locale.Tr "mail.register_notify.text_1" AppName}}

-

{{.locale.Tr "mail.register_notify.text_2" .Username}} -{{$set_pwd_url := printf "%suser/forgot_password" AppUrl}} -{{.locale.Tr "mail.register_notify.text_3" $set_pwd_url}}

-
- -
- Go to {{AppName}} -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{AppUrl}}user/login

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/themes/aurora/mail/user/auth/reset_passwd.tmpl b/themes/aurora/mail/user/auth/reset_passwd.tmpl index 8acb96a..3919672 100644 --- a/themes/aurora/mail/user/auth/reset_passwd.tmpl +++ b/themes/aurora/mail/user/auth/reset_passwd.tmpl @@ -4,51 +4,136 @@ - {{.locale.Tr "mail.reset_password.title" (.DisplayName|DotEscape)}} + + + {{.locale.Tr "mail.reset_password.title" (.DisplayName|DotEscape)}} + + - + +
- - - - - - - - - - +
- logo - {{AppName}} -
-

{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}

-

{{.locale.Tr "mail.reset_password.text" .ResetPwdCodeLives}}

-

-
- {{$recover_url := printf "%suser/recover_account?code=%s" AppUrl (QueryEscape .Code)}} -
- Reset Password -
-
-

{{.locale.Tr "mail.link_not_working_do_paste"}}

-

{{$recover_url}}

-
-
-

© {{AppName}} — Gitea Mail Templates

-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/tools/preview/locale.go b/tools/preview/locale.go index 3d98313..cca61c9 100644 --- a/tools/preview/locale.go +++ b/tools/preview/locale.go @@ -9,22 +9,38 @@ import ( // Locale provides English fallback translations, matching Gitea's locale.Tr interface. type Locale struct{} -// Tr translates a key and substitutes positional %s/%d arguments. +// Tr translates a key and substitutes %s / %d / %[N]s / %[N]d arguments. // HTML arguments are preserved; plain strings are HTML-escaped. func (l Locale) Tr(key string, args ...any) template.HTML { s := LocaleEN[key] if s == "" { s = key } - for _, arg := range args { + for i, arg := range args { var val string if h, ok := arg.(template.HTML); ok { - val = string(h) // already safe HTML — don't double-escape + val = string(h) // already safe HTML } else { val = template.HTMLEscapeString(fmt.Sprint(arg)) } + // Handle positional format specifiers: %[1]s, %[2]d, etc. + pos := fmt.Sprintf("%%[%d]", i+1) + s = strings.Replace(s, pos+"s", val, 1) + s = strings.Replace(s, pos+"d", val, 1) + } + // Fallback for non-positional %s / %d (sequential replacement) + for _, arg := range args { + var val string + if h, ok := arg.(template.HTML); ok { + val = string(h) + } else { + val = template.HTMLEscapeString(fmt.Sprint(arg)) + } + if !strings.Contains(s, "%s") && !strings.Contains(s, "%d") { + break + } s = strings.Replace(s, "%s", val, 1) - s = strings.Replace(s, "%d", fmt.Sprint(arg), 1) + s = strings.Replace(s, "%d", val, 1) } return template.HTML(s) } @@ -51,46 +67,64 @@ func (l Locale) TrN(count any, singular, plural string, args ...any) template.HT // LocaleEN holds all English translation strings used by Gitea mail templates. var LocaleEN = map[string]string{ - "mail.activate_account.title": "Activate your %s account", - "mail.hi_user_x": "Hi %s,", - "mail.activate_account.text_1": "Welcome to %s! Please activate your account by clicking the button below.", - "mail.activate_account.text_2": "This activation link will expire in %s.", - "mail.activate_email.title": "Verify your email address for %s", - "mail.activate_email.text": "Please verify your email address. The link will expire in %s.", - "mail.register_notify.title": "Welcome to %s, %s", - "mail.register_notify.text_1": "Your account on %s has been created successfully.", - "mail.register_notify.text_2": "Your username is: %s", - "mail.register_notify.text_3": "If you need to set a password, visit %s.", - "mail.reset_password.title": "Reset your %s password", - "mail.reset_password.text": "Click the link below to reset your password. It will expire in %s.", - "mail.link_not_working_do_paste": "If the button doesn't work, copy and paste this link into your browser:", - "mail.team_invite.text_1": "%s has invited you to join the team %s in the organization %s.", - "mail.team_invite.text_2": "Click the button below to accept the invitation.", - "mail.team_invite.text_3": "This invitation was sent to %s.", - "mail.repo.collaborator.added.text": "You have been added as a collaborator on the repository", - "mail.view_it_on": "View it on %s", - "mail.repo.transfer.body": "The repository %s has been transferred to you.", - "mail.release.new.text": "%s published a new release %s in the repository %s.", - "mail.release.title": "Release: %s", - "mail.release.note": "Release Notes:", - "mail.release.downloads": "Downloads", - "mail.release.download.zip": "Source Code (ZIP)", - "mail.release.download.targz": "Source Code (TAR.GZ)", - "mail.issue_assigned.pull": "%s assigned pull request %s to you in the repository %s.", - "mail.issue_assigned.issue": "%s assigned issue %s to you in the repository %s.", - "mail.issue.x_mentioned_you": "%s mentioned you.", - "mail.issue.action.close": "%s closed issue #%d.", - "mail.issue.action.reopen": "%s reopened issue #%d.", - "mail.issue.action.merge": "%s merged pull request #%d into %s.", - "mail.issue.action.approve": "%s approved this change.", - "mail.issue.action.reject": "%s requested changes.", - "mail.issue.action.review": "%s reviewed this change.", - "mail.issue.action.review_dismissed": "%s dismissed the review from %s.", - "mail.issue.action.ready_for_review": "%s marked this as ready for review.", - "mail.issue.action.new": "%s created issue #%d.", - "mail.issue.action.force_push": "%s force-pushed the %s branch from %s to %s.", - "mail.issue.action.push_1": "%s pushed %d commit to %s.", - "mail.issue.action.push_n": "%s pushed %d commits to %s.", - "mail.issue.in_tree_path": "In %s:", - "mail.reply": "Reply to this email", + "mail.hi_user_x": "Hi %s,", + "mail.activate_account": "Please activate your account", + "mail.activate_account.title": "%s, please activate your account", + "mail.activate_account.text_1": "Hi %[1]s, thanks for registering at %[2]s!", + "mail.activate_account.text_2": "Please click the following link to activate your account within %s:", + "mail.activate_email": "Verify your email address", + "mail.activate_email.title": "%s, please verify your email address", + "mail.activate_email.text": "Please click the following link to verify your email address within %s:", + "mail.register_success": "Registration successful", + "mail.register_notify": "Welcome to %s", + "mail.register_notify.title": "%[1]s, welcome to %[2]s", + "mail.register_notify.text_1": "This is your registration confirmation email for %s!", + "mail.register_notify.text_2": "You can now log in via username: %s.", + "mail.register_notify.text_3": "If this account has been created for you, please set your password first.", + "mail.reset_password": "Recover your account", + "mail.reset_password.title": "%s, you have requested to recover your account", + "mail.reset_password.text": "Please click the following link to recover your account within %s:", + "mail.team_invite.subject": "%[1]s has invited you to join the %[2]s organization", + "mail.team_invite.text_1": "%[1]s has invited you to join team %[2]s in organization %[3]s.", + "mail.team_invite.text_2": "Please click the following link to join the team:", + "mail.team_invite.text_3": "Note: This invitation was intended for %[1]s. If you were not expecting this invitation, you can ignore this email.", + "mail.repo.collaborator.added.subject": "%s added you to %s", + "mail.repo.collaborator.added.text": "You have been added as a collaborator of repository:", + "mail.repo.transfer.subject_to": "%s would like to transfer \"%s\" to %s", + "mail.repo.transfer.subject_to_you": "%s would like to transfer \"%s\" to you", + "mail.repo.transfer.to_you": "you", + "mail.repo.transfer.body": "To accept or reject it, visit %s or just ignore it.", + "mail.release.new.subject": "%s in %s released", + "mail.release.new.text": "@%[1]s released %[2]s in %[3]s", + "mail.release.title": "Title: %s", + "mail.release.note": "Note:", + "mail.release.downloads": "Downloads:", + "mail.release.download.zip": "Source Code (ZIP)", + "mail.release.download.targz": "Source Code (TAR.GZ)", + "mail.repo.actions.run.failed": "Run failed", + "mail.repo.actions.run.succeeded": "Run succeeded", + "mail.repo.actions.run.cancelled": "Run cancelled", + "mail.repo.actions.jobs.all_succeeded": "All jobs have succeeded", + "mail.repo.actions.jobs.all_failed": "All jobs have failed", + "mail.repo.actions.jobs.some_not_successful": "Some jobs were not successful", + "mail.repo.actions.jobs.all_cancelled": "All jobs have been cancelled", + "mail.issue_assigned.pull": "@%[1]s assigned you to pull request %[2]s in repository %[3]s.", + "mail.issue_assigned.issue": "@%[1]s assigned you to issue %[2]s in repository %[3]s.", + "mail.issue.x_mentioned_you": "@%s mentioned you:", + "mail.issue.action.close": "@%[1]s closed #%[2]d.", + "mail.issue.action.reopen": "@%[1]s reopened #%[2]d.", + "mail.issue.action.merge": "@%[1]s merged #%[2]d into %[3]s.", + "mail.issue.action.approve": "@%[1]s approved this pull request.", + "mail.issue.action.reject": "@%[1]s requested changes on this pull request.", + "mail.issue.action.review": "@%[1]s commented on this pull request.", + "mail.issue.action.review_dismissed": "@%[1]s dismissed last review from %[2]s for this pull request.", + "mail.issue.action.ready_for_review": "@%[1]s marked this pull request ready for review.", + "mail.issue.action.new": "@%[1]s created #%[2]d.", + "mail.issue.action.force_push": "%[1]s force-pushed the %[2]s from %[3]s to %[4]s.", + "mail.issue.action.push_1": "@%[1]s pushed %[3]d commit to %[2]s", + "mail.issue.action.push_n": "@%[1]s pushed %[3]d commits to %[2]s", + "mail.issue.in_tree_path": "In %s:", + "mail.view_it_on": "View it on %s", + "mail.reply": "or reply to this email directly", + "mail.link_not_working_do_paste": "Not working? Try copying and pasting it to your browser.", }