Skip to content

404 error for repo link in repository code search results when language is zh-CN or zh-TW #18051

@Joannazyx

Description

@Joannazyx

Gitea Version

1.15.5

Git Version

git version 2.34.1

Operating System

k8s

How are you running Gitea?

running 1.15.5 in docker

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

When language is set to zh-CN(简体中文) or zh-TW(繁体中文(台湾)), and start a code search in a repository, the repo link in results is a long path, and redirects to a 404 page.

image

In other languages, results of repository code search will only show repo name and the link is correct.
image

The reason seems obvious. The order of string fields in search.results is different in English and Chinese, but they use the same template.
code in templates\repo\search.tmpl, require order of string fields to be Keyword, RepoLink, RepoName.
{{if .Keyword}} <h3> {{.i18n.Tr "repo.search.results" (.Keyword|Escape) .RepoLink .RepoName | Str2html }} </h3>
code in options\locale\locale_en-US.ini
search.results = Search results for "%s" in <a href="%s">%s</a>

code in options\locale\ zh-CN and zh-TW
search.results=在 <a href="%s"> %s </a> 中搜索 "%s" 的结果

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions