substitute Gitea links in the translation files at build time

This commit is contained in:
Caesar Schinas 2022-12-26 01:29:44 -10:00 committed by Loïc Dachary
parent 308c93fdc9
commit cc8d0cb1c7
No known key found for this signature in database
GPG key ID: 992D23B392F9E4F2
2 changed files with 13 additions and 3 deletions

View file

@ -45,8 +45,18 @@ func renameGiteaForgejo(filename string) []byte {
line := scanner.Text()
if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
out = append(out, []byte("\n"+line+"\n")...)
} else if strings.Contains(line, "Gitea") {
out = append(out, []byte(strings.Replace(line, "Gitea", "Forgejo", -1)+"\n")...)
} else {
out = append(out, []byte(strings.NewReplacer(
"Gitea", "Forgejo",
"https://docs.gitea.io/en-us/install-from-binary/", "https://forgejo.org/download",
"https://github.com/go-gitea/gitea/tree/master/docker", "https://forgejo.org/download",
"https://docs.gitea.io/en-us/install-from-package/", "https://forgejo.org/download",
"https://code.gitea.io/gitea", "https://forgejo.org/download",
"code.gitea.io/gitea", "Forgejo",
`<a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a>`, `<a href="https://codeberg.org/forgejo/forgejo/issues" target="_blank">Codeberg</a>`,
"https://github.com/go-gitea/gitea", "https://codeberg.org/forgejo/forgejo",
"https://blog.gitea.io", "https://forgejo.org/news",
).Replace(line)+"\n")...)
}
}
file.Close()

View file

@ -184,7 +184,7 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool {
if err = db.InitEngine(ctx); err != nil {
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
ctx.Data["Err_DbType"] = true
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://docs.gitea.io/en-us/install-from-binary/"), tplInstall, form)
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://forgejo.org/download#installation-from-binary"), tplInstall, form)
} else {
ctx.Data["Err_DbSetting"] = true
ctx.RenderWithErr(ctx.Tr("install.invalid_db_setting", err), tplInstall, form)