diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-02-15 05:48:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 21:48:45 +0000 |
commit | f3eb835886031df7a562abc123c3f6011c81eca8 (patch) | |
tree | 6db218680b00a81f2ea46675d5dde94642a232b9 /routers/web/user/setting/profile.go | |
parent | 94d06be035bac468129903c9f32e785baf3c1c3b (diff) | |
download | gitea-f3eb835886031df7a562abc123c3f6011c81eca8.tar.gz gitea-f3eb835886031df7a562abc123c3f6011c81eca8.zip |
Refactor locale&string&template related code (#29165)
Clarify when "string" should be used (and be escaped), and when
"template.HTML" should be used (no need to escape)
And help PRs like #29059 , to render the error messages correctly.
Diffstat (limited to 'routers/web/user/setting/profile.go')
-rw-r--r-- | routers/web/user/setting/profile.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 95b350528c..24a807d518 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -126,7 +126,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * defer fr.Close() if form.Avatar.Size > setting.Avatar.MaxFileSize { - return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024)) + return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024)) } data, err := io.ReadAll(fr) @@ -136,7 +136,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * st := typesniffer.DetectContentType(data) if !(st.IsImage() && !st.IsSvgImage()) { - return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image")) + return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_not_a_image")) } if err = user_service.UploadAvatar(ctx, ctxUser, data); err != nil { return fmt.Errorf("UploadAvatar: %w", err) @@ -389,7 +389,7 @@ func UpdateUserLang(ctx *context.Context) { middleware.SetLocaleCookie(ctx.Resp, ctx.Doer.Language, 0) log.Trace("User settings updated: %s", ctx.Doer.Name) - ctx.Flash.Success(translation.NewLocale(ctx.Doer.Language).Tr("settings.update_language_success")) + ctx.Flash.Success(translation.NewLocale(ctx.Doer.Language).TrString("settings.update_language_success")) ctx.Redirect(setting.AppSubURL + "/user/settings/appearance") } |