-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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, use Locale to provide i18n/translation related functions #18648
Conversation
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
"AllLangs": translation.AllLangs(), | ||
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this removal intended? There are still other places which set it and head_navbar.tmpl
uses it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The install page do not need it, I have searched the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
install.tmpl
only includes head.tmpl
, which says:
{{if not .PageIsInstall}}
<div class="ui top secondary stackable main menu following bar light">
{{template "base/head_navbar" .}}
</div><!-- end bar -->
{{end}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to attach a screenshot of the install page rendered with this commit to prove the removal of the CurrentURL, Language, Lang
fields are of no consequence since there is no test to verify that.
I have tested them, including issue activity pages, etc, screenshot shows no difference. |
@@ -25,17 +25,18 @@ type Locale interface { | |||
|
|||
// LangType represents a lang type | |||
type LangType struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a crazy idea here but can't we unify this with type locale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's feasible, and we could make a better locale struct.
In fact I had a plan to refactor all {{TimeSince .StartTime $.i18n.Lang}}
to {{i18nUtil.TimeSince .StartTime}}
to make code more simple and clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think LangType and locale could be unified.
otherwise LGTM.
Codecov Report
@@ Coverage Diff @@
## main #18648 +/- ##
==========================================
+ Coverage 46.31% 46.67% +0.36%
==========================================
Files 846 846
Lines 121244 121266 +22
==========================================
+ Hits 56155 56606 +451
+ Misses 58271 57790 -481
- Partials 6818 6870 +52
Continue to review full report at Codecov.
|
* giteaofficial/main: (28 commits) Added auto-save whitespace behavior if it changed manually (go-gitea#15566) Support custom ACME provider (go-gitea#18340) Refactor i18n, use Locale to provide i18n/translation related functions (go-gitea#18648) Only request write when necessary (go-gitea#18657) [skip ci] Updated translations via Crowdin Add separate SSH_USER config option (go-gitea#17584) Be more lenient with label colors (go-gitea#17752) remove redundant call to UpdateRepoStats during migration (go-gitea#18591) more repo dump/restore tests, including pull requests (go-gitea#18621) No longer show the db-downgrade SQL in production (go-gitea#18653) Fix the missing i18n key for update checker (go-gitea#18646) Update gitea-vet (go-gitea#18640) Future proof for 1.18 (go-gitea#18644) Add `contrib/upgrade.sh` (go-gitea#18286) If rendering has failed due to a net.OpError stop rendering (go-gitea#18642) Delete old git.NewCommand() and use it as git.NewCommandContext() (go-gitea#18552) Update JS dependencies (go-gitea#18636) fix commits_list_small.tmpl (go-gitea#18641) Fix `make fmt` and `make fmt-check` (go-gitea#18633) Frontport of changelog for v1.16.1 (go-gitea#18615) ...
…ns (go-gitea#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
This PR:
Locale
for _, lang := range translation.AllLangs()
for every request, which improves the performance slightlyctx.Locale.Language()
instead ofctx.Data["Lang"].(string)