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

Clean up template locale usage #27856

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Clean up template locale usage #27856

merged 1 commit into from
Oct 31, 2023

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Oct 31, 2023

After many refactoring PRs for the "locale" and "template context function", now the ".locale" is not needed for web templates any more.

This PR does a clean up for:

  1. Remove ctx.Data["locale"] for web context.
  2. Use ctx.Locale in 500.tmpl, for consistency.
  3. Add a test check for 500 page locale usage.
  4. Remove the Str2html and DotEscape from mail template context data, they are copy&paste errors introduced by Try to prevent autolinking of displaynames in activation emails by email readers #19169 and Localize Email Templates #16200 . These functions are template functions (provided by the common renderer), but not template data variables.
  5. Make email SendAsync function mockable (I was planning to add more tests but it would make this PR much too complex, so the tests could be done in another PR)

@wxiaoguang wxiaoguang added the backport/v1.21 This PR should be backported to Gitea 1.21 label Oct 31, 2023
@wxiaoguang wxiaoguang added this to the 1.22.0 milestone Oct 31, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 31, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 31, 2023
@wxiaoguang wxiaoguang added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Oct 31, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 31, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 31, 2023
@denyskon denyskon added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 31, 2023
@lunny lunny merged commit a4b242a into go-gitea:main Oct 31, 2023
25 checks passed
@GiteaBot
Copy link
Contributor

I was unable to create a backport for 1.21. @wxiaoguang, please send one manually. 🍵

go run ./contrib/backport 27856
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added backport/manual No power to the bots! Create your backport yourself! and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Oct 31, 2023
@wxiaoguang wxiaoguang deleted the fix-locale branch October 31, 2023 14:33
@wxiaoguang wxiaoguang added the backport/done All backports for this PR have been created label Oct 31, 2023
silverwind pushed a commit that referenced this pull request Oct 31, 2023
Backport #27856

The only conflict is `ThemeName` in `500.tmpl`, it has been resolved
manually by keeping using old
`{{.SignedUser.Theme}}{{else}}{{DefaultTheme}}`
zjjhot added a commit to zjjhot/gitea that referenced this pull request Nov 1, 2023
* giteaofficial/main:
  Clean up template locale usage (go-gitea#27856)
@lng2020 lng2020 removed the backport/manual No power to the bots! Create your backport yourself! label Nov 12, 2023
fuxiaohei pushed a commit to fuxiaohei/gitea that referenced this pull request Jan 17, 2024
After many refactoring PRs for the "locale" and "template context
function", now the ".locale" is not needed for web templates any more.

This PR does a clean up for:

1. Remove `ctx.Data["locale"]` for web context.
2. Use `ctx.Locale` in `500.tmpl`, for consistency.
3. Add a test check for `500 page` locale usage.
4. Remove the `Str2html` and `DotEscape` from mail template context
data, they are copy&paste errors introduced by go-gitea#19169 and go-gitea#16200 . These
functions are template functions (provided by the common renderer), but
not template data variables.
5. Make email `SendAsync` function mockable (I was planning to add more
tests but it would make this PR much too complex, so the tests could be
done in another PR)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants