-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Changes from 3 commits
46bde10
5f294eb
fcd2b60
bfd6b15
3142cae
ac74fb0
05301e2
a562a58
0ecd380
9127d16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,25 +71,16 @@ func Init(next http.Handler) http.Handler { | |
Render: rnd, | ||
Session: session.GetSession(req), | ||
Data: map[string]interface{}{ | ||
"i18n": locale, | ||
"Title": locale.Tr("install.install"), | ||
"PageIsInstall": true, | ||
"DbTypeNames": getDbTypeNames(), | ||
"i18n": locale, | ||
"Language": locale.Language(), | ||
"Lang": locale.Language(), | ||
"AllLangs": translation.AllLangs(), | ||
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"PageStartTime": startTime, | ||
|
||
"PasswordHashAlgorithms": user_model.AvailableHashAlgorithms, | ||
}, | ||
} | ||
for _, lang := range translation.AllLangs() { | ||
if lang.Lang == locale.Language() { | ||
ctx.Data["LangName"] = lang.Name | ||
break | ||
} | ||
} | ||
ctx.Req = context.WithContext(req, &ctx) | ||
next.ServeHTTP(resp, ctx.Req) | ||
}) | ||
|
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.