This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch test in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit b144fc678f74d72f5989d55b82cbb717937fc99b Author: Kevin Gil <[email protected]> AuthorDate: Fri Jun 21 00:45:27 2024 -0700 website information in the template file now supports multiple languages --- i18n/en_US.yaml | 7 +++++++ internal/base/constant/question.go | 3 +++ internal/controller/template_controller.go | 9 +++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index ca89ae59..88fd6e7f 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -415,6 +415,13 @@ backend: other: modified deleted_title: other: Deleted question + questions_title: + other: Questions + tag: + tags_title: + other: Tags + no_description: + other: The tag has no description. notification: action: update_question: diff --git a/internal/base/constant/question.go b/internal/base/constant/question.go index 69e66255..f1962208 100644 --- a/internal/base/constant/question.go +++ b/internal/base/constant/question.go @@ -21,4 +21,7 @@ package constant const ( DeletedQuestionTitleTrKey = "question.deleted_title" + QuestionsTitleTrKey = "question.questions_title" + TagsListTitleTrKey = "tag.tags_title" + TagHasNoDescription = "tag.no_description" ) diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go index b1738b00..5c89ad48 100644 --- a/internal/controller/template_controller.go +++ b/internal/controller/template_controller.go @@ -31,6 +31,7 @@ import ( "github.com/apache/incubator-answer/internal/base/constant" "github.com/apache/incubator-answer/internal/base/handler" + "github.com/apache/incubator-answer/internal/base/translator" templaterender "github.com/apache/incubator-answer/internal/controller/template_render" "github.com/apache/incubator-answer/internal/entity" "github.com/apache/incubator-answer/internal/schema" @@ -176,7 +177,7 @@ func (tc *TemplateController) QuestionList(ctx *gin.Context) { if siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitle { UrlUseTitle = true } - siteInfo.Title = fmt.Sprintf("Questions - %s", siteInfo.General.Name) + siteInfo.Title = fmt.Sprintf("%s - %s", translator.Tr(handler.GetLang(ctx), constant.QuestionsTitleTrKey), siteInfo.General.Name) tc.html(ctx, http.StatusOK, "question.html", siteInfo, gin.H{ "data": data, "useTitle": UrlUseTitle, @@ -411,7 +412,7 @@ func (tc *TemplateController) TagList(ctx *gin.Context) { if req.Page > 1 { siteInfo.Canonical = fmt.Sprintf("%s/tags?page=%d", siteInfo.General.SiteUrl, req.Page) } - siteInfo.Title = fmt.Sprintf("%s - %s", "Tags", siteInfo.General.Name) + siteInfo.Title = fmt.Sprintf("%s - %s", translator.Tr(handler.GetLang(ctx), constant.TagsListTitleTrKey), siteInfo.General.Name) tc.html(ctx, http.StatusOK, "tags.html", siteInfo, gin.H{ "page": page, "data": data, @@ -442,7 +443,7 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) { } siteInfo.Description = htmltext.FetchExcerpt(taginifo.ParsedText, "...", 240) if len(taginifo.ParsedText) == 0 { - siteInfo.Description = "The tag has no description." + siteInfo.Description = translator.Tr(handler.GetLang(ctx), constant.TagHasNoDescription) } siteInfo.Keywords = taginifo.DisplayName @@ -450,7 +451,7 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) { if siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitle { UrlUseTitle = true } - siteInfo.Title = fmt.Sprintf("'%s' Questions - %s", taginifo.DisplayName, siteInfo.General.Name) + siteInfo.Title = fmt.Sprintf("'%s' %s - %s", taginifo.DisplayName, translator.Tr(handler.GetLang(ctx), constant.QuestionsTitleTrKey), siteInfo.General.Name) tc.html(ctx, http.StatusOK, "tag-detail.html", siteInfo, gin.H{ "tag": taginifo, "questionList": questionList,
