Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions internal/base/constant/question.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ package constant

const (
DeletedQuestionTitleTrKey = "question.deleted_title"
QuestionsTitleTrKey = "question.questions_title"
TagsListTitleTrKey = "tag.tags_title"
TagHasNoDescription = "tag.no_description"
)
19 changes: 10 additions & 9 deletions internal/controller/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -428,7 +429,7 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {
}
nowPage := req.Page
req.Name = tag
taginifo, questionList, questionCount, err := tc.templateRenderController.TagInfo(ctx, req)
tagInfo, questionList, questionCount, err := tc.templateRenderController.TagInfo(ctx, req)
if err != nil {
tc.Page404(ctx)
return
Expand All @@ -440,19 +441,19 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {
if req.Page > 1 {
siteInfo.Canonical = fmt.Sprintf("%s/tags/%s?page=%d", siteInfo.General.SiteUrl, tag, req.Page)
}
siteInfo.Description = htmltext.FetchExcerpt(taginifo.ParsedText, "...", 240)
if len(taginifo.ParsedText) == 0 {
siteInfo.Description = "The tag has no description."
siteInfo.Description = htmltext.FetchExcerpt(tagInfo.ParsedText, "...", 240)
if len(tagInfo.ParsedText) == 0 {
siteInfo.Description = translator.Tr(handler.GetLang(ctx), constant.TagHasNoDescription)
}
siteInfo.Keywords = taginifo.DisplayName
siteInfo.Keywords = tagInfo.DisplayName

UrlUseTitle := false
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", tagInfo.DisplayName, translator.Tr(handler.GetLang(ctx), constant.QuestionsTitleTrKey), siteInfo.General.Name)
tc.html(ctx, http.StatusOK, "tag-detail.html", siteInfo, gin.H{
"tag": taginifo,
"tag": tagInfo,
"questionList": questionList,
"questionCount": questionCount,
"useTitle": UrlUseTitle,
Expand Down