aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Dachary2023-03-13 00:55:14 +0100
committerLoïc Dachary2023-03-13 00:55:14 +0100
commit6f3665bcf228da3339d3f42038aa402f9e621544 (patch)
tree2a2c75a30debbda0abea74a031aa09609f703088
parenteaeb9f183ff9fdb9710b776bb26b0920e34065c0 (diff)
parentbd4dc797c7cc599d2aca05b7d1ee2a6532dd0358 (diff)
Merge remote-tracking branch 'forgejo/forgejo-i18n' into forgejo
-rw-r--r--.gitignore3
-rw-r--r--Makefile14
-rw-r--r--build/merge-forgejo-locales.go97
-rw-r--r--options/locales/gitea_cs-CZ.ini (renamed from options/locale/locale_cs-CZ.ini)0
-rw-r--r--options/locales/gitea_de-DE.ini (renamed from options/locale/locale_de-DE.ini)0
-rw-r--r--options/locales/gitea_el-GR.ini (renamed from options/locale/locale_el-GR.ini)0
-rw-r--r--options/locales/gitea_en-US.ini (renamed from options/locale/locale_en-US.ini)0
-rw-r--r--options/locales/gitea_es-ES.ini (renamed from options/locale/locale_es-ES.ini)0
-rw-r--r--options/locales/gitea_fa-IR.ini (renamed from options/locale/locale_fa-IR.ini)0
-rw-r--r--options/locales/gitea_fi-FI.ini (renamed from options/locale/locale_fi-FI.ini)0
-rw-r--r--options/locales/gitea_fr-FR.ini (renamed from options/locale/locale_fr-FR.ini)0
-rw-r--r--options/locales/gitea_hu-HU.ini (renamed from options/locale/locale_hu-HU.ini)0
-rw-r--r--options/locales/gitea_id-ID.ini (renamed from options/locale/locale_id-ID.ini)0
-rw-r--r--options/locales/gitea_is-IS.ini (renamed from options/locale/locale_is-IS.ini)0
-rw-r--r--options/locales/gitea_it-IT.ini (renamed from options/locale/locale_it-IT.ini)0
-rw-r--r--options/locales/gitea_ja-JP.ini (renamed from options/locale/locale_ja-JP.ini)0
-rw-r--r--options/locales/gitea_ko-KR.ini (renamed from options/locale/locale_ko-KR.ini)0
-rw-r--r--options/locales/gitea_lv-LV.ini (renamed from options/locale/locale_lv-LV.ini)0
-rw-r--r--options/locales/gitea_nl-NL.ini (renamed from options/locale/locale_nl-NL.ini)0
-rw-r--r--options/locales/gitea_pl-PL.ini (renamed from options/locale/locale_pl-PL.ini)0
-rw-r--r--options/locales/gitea_pt-BR.ini (renamed from options/locale/locale_pt-BR.ini)0
-rw-r--r--options/locales/gitea_pt-PT.ini (renamed from options/locale/locale_pt-PT.ini)0
-rw-r--r--options/locales/gitea_ru-RU.ini (renamed from options/locale/locale_ru-RU.ini)0
-rw-r--r--options/locales/gitea_si-LK.ini (renamed from options/locale/locale_si-LK.ini)0
-rw-r--r--options/locales/gitea_sk-SK.ini (renamed from options/locale/locale_sk-SK.ini)0
-rw-r--r--options/locales/gitea_sv-SE.ini (renamed from options/locale/locale_sv-SE.ini)0
-rw-r--r--options/locales/gitea_tr-TR.ini (renamed from options/locale/locale_tr-TR.ini)0
-rw-r--r--options/locales/gitea_uk-UA.ini (renamed from options/locale/locale_uk-UA.ini)0
-rw-r--r--options/locales/gitea_zh-CN.ini (renamed from options/locale/locale_zh-CN.ini)0
-rw-r--r--options/locales/gitea_zh-HK.ini (renamed from options/locale/locale_zh-HK.ini)0
-rw-r--r--options/locales/gitea_zh-TW.ini (renamed from options/locale/locale_zh-TW.ini)0
31 files changed, 106 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 6d9eceb30..6ec3c3fae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,3 +115,6 @@ prime/
# Manpage
/man
+
+# Generated merged Forgejo+Gitea language files
+/options/locale/locale_*
diff --git a/Makefile b/Makefile
index 60bbf5851..1d82432b3 100644
--- a/Makefile
+++ b/Makefile
@@ -769,10 +769,14 @@ generate: generate-backend
generate-backend: $(TAGS_PREREQ) generate-go
.PHONY: generate-go
-generate-go: $(TAGS_PREREQ)
+generate-go: $(TAGS_PREREQ) merge-locales
@echo "Running go generate..."
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
+.PHONY: merge-locales
+merge-locales:
+ $(GO) run build/merge-forgejo-locales.go
+
.PHONY: security-check
security-check:
go run $(GOVULNCHECK_PACKAGE) -v ./...
@@ -934,13 +938,7 @@ lockfile-check:
.PHONY: update-translations
update-translations:
- mkdir -p ./translations
- cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
- rm ./translations/gitea.zip
- $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
- $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
- mv ./translations/*.ini ./options/locale/
- rmdir ./translations
+ # noop to detect merge conflicts (potentially needs updating the scripts) and avoid breaking with Gitea
.PHONY: generate-license
generate-license:
diff --git a/build/merge-forgejo-locales.go b/build/merge-forgejo-locales.go
new file mode 100644
index 000000000..0e6b345f2
--- /dev/null
+++ b/build/merge-forgejo-locales.go
@@ -0,0 +1,97 @@
+// Copyright 2022 The Forgejo Authors c/o Codeberg e.V.. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+//go:build ignore
+
+package main
+
+import (
+ "bufio"
+ "os"
+ "regexp"
+ "strings"
+
+ "gopkg.in/ini.v1"
+)
+
+const (
+ trimPrefix = "gitea_"
+ sourceFolder = "options/locales/"
+)
+
+// returns list of locales, still containing the file extension!
+func generate_locale_list() []string {
+ localeFiles, _ := os.ReadDir(sourceFolder)
+ locales := []string{}
+ for _, localeFile := range localeFiles {
+ if !localeFile.IsDir() && strings.HasPrefix(localeFile.Name(), trimPrefix) {
+ locales = append(locales, strings.TrimPrefix(localeFile.Name(), trimPrefix))
+ }
+ }
+ return locales
+}
+
+// replace all occurrences of Gitea with Forgejo
+func renameGiteaForgejo(filename string) []byte {
+ file, err := os.Open(filename)
+ if err != nil {
+ panic(err)
+ }
+
+ replacer := strings.NewReplacer(
+ "Gitea", "Forgejo",
+ "https://docs.gitea.io/en-us/install-from-binary/", "https://forgejo.org/download/#installation-from-binary",
+ "https://github.com/go-gitea/gitea/tree/master/docker", "https://forgejo.org/download/#container-image",
+ "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",
+ )
+
+ out := make([]byte, 0, 1024)
+ scanner := bufio.NewScanner(file)
+ scanner.Split(bufio.ScanLines)
+ for scanner.Scan() {
+ line := scanner.Text()
+
+ if strings.HasPrefix(line, "license_desc=") {
+ line = strings.Replace(line, "GitHub", "Forgejo", 1)
+ }
+
+ if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
+ out = append(out, []byte("\n"+line+"\n")...)
+ } else if strings.HasPrefix(line, "settings.web_hook_name_gitea") {
+ out = append(out, []byte("\n"+line+"\n")...)
+ out = append(out, []byte("settings.web_hook_name_forgejo = Forgejo\n")...)
+ } else if strings.HasPrefix(line, "migrate.gitea.description") {
+ re := regexp.MustCompile(`(.*Gitea)`)
+ out = append(out, []byte(re.ReplaceAllString(line, "${1}/Forgejo")+"\n")...)
+ } else {
+ out = append(out, []byte(replacer.Replace(line)+"\n")...)
+ }
+ }
+ file.Close()
+ return out
+}
+
+func main() {
+ locales := generate_locale_list()
+ var err error
+ var localeFile *ini.File
+ for _, locale := range locales {
+ giteaLocale := sourceFolder + "gitea_" + locale
+ localeFile, err = ini.LoadSources(ini.LoadOptions{
+ IgnoreInlineComment: true,
+ }, giteaLocale, renameGiteaForgejo(giteaLocale))
+ if err != nil {
+ panic(err)
+ }
+ err = localeFile.SaveTo("options/locale/locale_" + locale)
+ if err != nil {
+ panic(err)
+ }
+ }
+}
diff --git a/options/locale/locale_cs-CZ.ini b/options/locales/gitea_cs-CZ.ini
index 543cd4404..543cd4404 100644
--- a/options/locale/locale_cs-CZ.ini
+++ b/options/locales/gitea_cs-CZ.ini
diff --git a/options/locale/locale_de-DE.ini b/options/locales/gitea_de-DE.ini
index 9bee2104e..9bee2104e 100644
--- a/options/locale/locale_de-DE.ini
+++ b/options/locales/gitea_de-DE.ini
diff --git a/options/locale/locale_el-GR.ini b/options/locales/gitea_el-GR.ini
index 6affdf7e8..6affdf7e8 100644
--- a/options/locale/locale_el-GR.ini
+++ b/options/locales/gitea_el-GR.ini
diff --git a/options/locale/locale_en-US.ini b/options/locales/gitea_en-US.ini
index dccf18433..dccf18433 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locales/gitea_en-US.ini
diff --git a/options/locale/locale_es-ES.ini b/options/locales/gitea_es-ES.ini
index f104d3c49..f104d3c49 100644
--- a/options/locale/locale_es-ES.ini
+++ b/options/locales/gitea_es-ES.ini
diff --git a/options/locale/locale_fa-IR.ini b/options/locales/gitea_fa-IR.ini
index 449da63b7..449da63b7 100644
--- a/options/locale/locale_fa-IR.ini
+++ b/options/locales/gitea_fa-IR.ini
diff --git a/options/locale/locale_fi-FI.ini b/options/locales/gitea_fi-FI.ini
index a589d12c2..a589d12c2 100644
--- a/options/locale/locale_fi-FI.ini
+++ b/options/locales/gitea_fi-FI.ini
diff --git a/options/locale/locale_fr-FR.ini b/options/locales/gitea_fr-FR.ini
index 15d20011e..15d20011e 100644
--- a/options/locale/locale_fr-FR.ini
+++ b/options/locales/gitea_fr-FR.ini
diff --git a/options/locale/locale_hu-HU.ini b/options/locales/gitea_hu-HU.ini
index 328af14d5..328af14d5 100644
--- a/options/locale/locale_hu-HU.ini
+++ b/options/locales/gitea_hu-HU.ini
diff --git a/options/locale/locale_id-ID.ini b/options/locales/gitea_id-ID.ini
index 5b418231c..5b418231c 100644
--- a/options/locale/locale_id-ID.ini
+++ b/options/locales/gitea_id-ID.ini
diff --git a/options/locale/locale_is-IS.ini b/options/locales/gitea_is-IS.ini
index bd596105d..bd596105d 100644
--- a/options/locale/locale_is-IS.ini
+++ b/options/locales/gitea_is-IS.ini
diff --git a/options/locale/locale_it-IT.ini b/options/locales/gitea_it-IT.ini
index d77baee6e..d77baee6e 100644
--- a/options/locale/locale_it-IT.ini
+++ b/options/locales/gitea_it-IT.ini
diff --git a/options/locale/locale_ja-JP.ini b/options/locales/gitea_ja-JP.ini
index 8e77329f5..8e77329f5 100644
--- a/options/locale/locale_ja-JP.ini
+++ b/options/locales/gitea_ja-JP.ini
diff --git a/options/locale/locale_ko-KR.ini b/options/locales/gitea_ko-KR.ini
index ca642ebf0..ca642ebf0 100644
--- a/options/locale/locale_ko-KR.ini
+++ b/options/locales/gitea_ko-KR.ini
diff --git a/options/locale/locale_lv-LV.ini b/options/locales/gitea_lv-LV.ini
index 0f7862f8a..0f7862f8a 100644
--- a/options/locale/locale_lv-LV.ini
+++ b/options/locales/gitea_lv-LV.ini
diff --git a/options/locale/locale_nl-NL.ini b/options/locales/gitea_nl-NL.ini
index 450df1c3a..450df1c3a 100644
--- a/options/locale/locale_nl-NL.ini
+++ b/options/locales/gitea_nl-NL.ini
diff --git a/options/locale/locale_pl-PL.ini b/options/locales/gitea_pl-PL.ini
index e43e7a554..e43e7a554 100644
--- a/options/locale/locale_pl-PL.ini
+++ b/options/locales/gitea_pl-PL.ini
diff --git a/options/locale/locale_pt-BR.ini b/options/locales/gitea_pt-BR.ini
index 55529df88..55529df88 100644
--- a/options/locale/locale_pt-BR.ini
+++ b/options/locales/gitea_pt-BR.ini
diff --git a/options/locale/locale_pt-PT.ini b/options/locales/gitea_pt-PT.ini
index ef7a400ec..ef7a400ec 100644
--- a/options/locale/locale_pt-PT.ini
+++ b/options/locales/gitea_pt-PT.ini
diff --git a/options/locale/locale_ru-RU.ini b/options/locales/gitea_ru-RU.ini
index 9516a2963..9516a2963 100644
--- a/options/locale/locale_ru-RU.ini
+++ b/options/locales/gitea_ru-RU.ini
diff --git a/options/locale/locale_si-LK.ini b/options/locales/gitea_si-LK.ini
index 1f8700900..1f8700900 100644
--- a/options/locale/locale_si-LK.ini
+++ b/options/locales/gitea_si-LK.ini
diff --git a/options/locale/locale_sk-SK.ini b/options/locales/gitea_sk-SK.ini
index 87942926e..87942926e 100644
--- a/options/locale/locale_sk-SK.ini
+++ b/options/locales/gitea_sk-SK.ini
diff --git a/options/locale/locale_sv-SE.ini b/options/locales/gitea_sv-SE.ini
index c79f99d51..c79f99d51 100644
--- a/options/locale/locale_sv-SE.ini
+++ b/options/locales/gitea_sv-SE.ini
diff --git a/options/locale/locale_tr-TR.ini b/options/locales/gitea_tr-TR.ini
index 131dfa69a..131dfa69a 100644
--- a/options/locale/locale_tr-TR.ini
+++ b/options/locales/gitea_tr-TR.ini
diff --git a/options/locale/locale_uk-UA.ini b/options/locales/gitea_uk-UA.ini
index 3f39f0baf..3f39f0baf 100644
--- a/options/locale/locale_uk-UA.ini
+++ b/options/locales/gitea_uk-UA.ini
diff --git a/options/locale/locale_zh-CN.ini b/options/locales/gitea_zh-CN.ini
index aa4cc4dde..aa4cc4dde 100644
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locales/gitea_zh-CN.ini
diff --git a/options/locale/locale_zh-HK.ini b/options/locales/gitea_zh-HK.ini
index 6fa062fc6..6fa062fc6 100644
--- a/options/locale/locale_zh-HK.ini
+++ b/options/locales/gitea_zh-HK.ini
diff --git a/options/locale/locale_zh-TW.ini b/options/locales/gitea_zh-TW.ini
index e98e55b77..e98e55b77 100644
--- a/options/locale/locale_zh-TW.ini
+++ b/options/locales/gitea_zh-TW.ini