From 54dd7d13a10da1d3ccb0fbe7e50b874ea2aec31f Mon Sep 17 00:00:00 2001 From: fnetx Date: Wed, 14 Dec 2022 19:23:56 +0100 Subject: [PATCH 1/4] [I18N] Rename upstream files (cherry picked from commit 2d67a9a62163957eef9dd26379a229b8af741655) (cherry picked from commit 4eac51f6a4200e01aa72fa0eaac5d72d57ed0c8e) (cherry picked from commit 34401a28f5d1180ac580c3410209b5291428a156) (cherry picked from commit 7210b45a61f52b3c6396c339dc525d5b58c32b54) (cherry picked from commit cc741116d2e1423d005869b244054b41b402dc3e) (cherry picked from commit 67a160ef0abca208610d1395a2218aab26c181a3) (cherry picked from commit adb258767259f3e8802485990a0625bc151f364b) (cherry picked from commit 1b57a3d6011d4b9790199cc1beb4d2220f45bb09) (cherry picked from commit 02fbbf05384190ca3f81e6bd920e3cbe2a9cd260) (cherry picked from commit 164af88c4b002cc8fcaaba0551608a25236a836d) (cherry picked from commit 5102d0aded75df2d171fbc9d5763f5918663fe7e) (cherry picked from commit f1e1e620f475d2935c2cb487574af93a5e9bb90e) (cherry picked from commit 2bd4ab7b4635fff63552c003782f05e63fb84f3d) (cherry picked from commit 28b511a33a2b778cf456bfaae02dc431d3c4d48e) (cherry picked from commit dc501ba1c160ed5c401c9e21fcfddd21ee00254d) (cherry picked from commit 252d336537286da57ec486cb43906c026c72943a) (cherry picked from commit 8208f11db036e2d80b28a03d523f766ed69bfa43) (cherry picked from commit da711c70b59b1d464a773be95a67eee3360ec6a4) (cherry picked from commit 62e9a4d9179dc11cb9752fc327fb5788a259b5a2) (cherry picked from commit 7fe6e090735aa1df498c0b2b9a63b983906fa7ec) (cherry picked from commit cfd6782313db3e1de219b5cd9d64a556234ea2c9) (cherry picked from commit 5188e3a0f1eb502b4b6266a828cd06a8ec748a77) (cherry picked from commit 5d741ae4406ddf04126e689d6320ef29b84bfeda) (cherry picked from commit b8a72e0111ddc03c583daf6432dd6aa3e507c4f9) (cherry picked from commit 2fbbf1ef8d4342260eede975e42264a8fde072bb) (cherry picked from commit 33597ea6c0426c7d218e5fd3511e0582e9e3720e) (cherry picked from commit 966e0cf8c01a23a7d58583214389d22d96900cd1) (cherry picked from commit 38d0da916793d4e420f068bb934c5143292177f4) (cherry picked from commit b740ebf5f6a4db0a802abf7ac1f731ca82b30bc6) (cherry picked from commit 36e0978f6e2bd59a20752063480f1c85c07947ab) (cherry picked from commit 98e157c22223b7e4f3dcad34824e7430104848a0) (cherry picked from commit 1ec680eb7fbfda59bf6336ad83cfdfc98759f205) (cherry picked from commit 23848b7ce739557cafd9f6aece789f10b7f308da) (cherry picked from commit 431c925de486848a15b48d5bf8cd5af30ce1fb50) (cherry picked from commit df9e026d9239f839ac0b8fd35614325ba183e468) (cherry picked from commit 39d97780a109aeee81fe230053e0c43b68572b93) (cherry picked from commit 7e266cce10d71dc443904668de41bfd226c99003) (cherry picked from commit 516de5fd8f4f9f2265ad9d493c3b3dd8438c5229) (cherry picked from commit 1bd5eba7e722ed82dd9f8126aeaa4a9527664250) (cherry picked from commit 45d01bcd389933a29a66ed237828a7b23bc87752) (cherry picked from commit 71734355d0db1c3af671f7d37d09264a6626feed) (cherry picked from commit 6a1a33c34c6c4467cd305bd9ec44a39cf1e93cf2) (cherry picked from commit 829715aa21be078424a44f623bbbf62831fb7972) (cherry picked from commit 7c06b5f9ea1efc569e4757d9ee76ece3b80c96ff) (cherry picked from commit 90ab1b3c6294a9050c98be73a14db78e810fc180) (cherry picked from commit cf6b103868913aec5f6795a268c74e3f07e7f760) --- options/locale/{locale_cs-CZ.ini => gitea_cs-CZ.ini} | 0 options/locale/{locale_de-DE.ini => gitea_de-DE.ini} | 0 options/locale/{locale_el-GR.ini => gitea_el-GR.ini} | 0 options/locale/{locale_en-US.ini => gitea_en-US.ini} | 0 options/locale/{locale_es-ES.ini => gitea_es-ES.ini} | 0 options/locale/{locale_fa-IR.ini => gitea_fa-IR.ini} | 0 options/locale/{locale_fi-FI.ini => gitea_fi-FI.ini} | 0 options/locale/{locale_fr-FR.ini => gitea_fr-FR.ini} | 0 options/locale/{locale_hu-HU.ini => gitea_hu-HU.ini} | 0 options/locale/{locale_id-ID.ini => gitea_id-ID.ini} | 0 options/locale/{locale_is-IS.ini => gitea_is-IS.ini} | 0 options/locale/{locale_it-IT.ini => gitea_it-IT.ini} | 0 options/locale/{locale_ja-JP.ini => gitea_ja-JP.ini} | 0 options/locale/{locale_ko-KR.ini => gitea_ko-KR.ini} | 0 options/locale/{locale_lv-LV.ini => gitea_lv-LV.ini} | 0 options/locale/{locale_nl-NL.ini => gitea_nl-NL.ini} | 0 options/locale/{locale_pl-PL.ini => gitea_pl-PL.ini} | 0 options/locale/{locale_pt-BR.ini => gitea_pt-BR.ini} | 0 options/locale/{locale_pt-PT.ini => gitea_pt-PT.ini} | 0 options/locale/{locale_ru-RU.ini => gitea_ru-RU.ini} | 0 options/locale/{locale_si-LK.ini => gitea_si-LK.ini} | 0 options/locale/{locale_sk-SK.ini => gitea_sk-SK.ini} | 0 options/locale/{locale_sv-SE.ini => gitea_sv-SE.ini} | 0 options/locale/{locale_tr-TR.ini => gitea_tr-TR.ini} | 0 options/locale/{locale_uk-UA.ini => gitea_uk-UA.ini} | 0 options/locale/{locale_zh-CN.ini => gitea_zh-CN.ini} | 0 options/locale/{locale_zh-HK.ini => gitea_zh-HK.ini} | 0 options/locale/{locale_zh-TW.ini => gitea_zh-TW.ini} | 0 28 files changed, 0 insertions(+), 0 deletions(-) rename options/locale/{locale_cs-CZ.ini => gitea_cs-CZ.ini} (100%) rename options/locale/{locale_de-DE.ini => gitea_de-DE.ini} (100%) rename options/locale/{locale_el-GR.ini => gitea_el-GR.ini} (100%) rename options/locale/{locale_en-US.ini => gitea_en-US.ini} (100%) rename options/locale/{locale_es-ES.ini => gitea_es-ES.ini} (100%) rename options/locale/{locale_fa-IR.ini => gitea_fa-IR.ini} (100%) rename options/locale/{locale_fi-FI.ini => gitea_fi-FI.ini} (100%) rename options/locale/{locale_fr-FR.ini => gitea_fr-FR.ini} (100%) rename options/locale/{locale_hu-HU.ini => gitea_hu-HU.ini} (100%) rename options/locale/{locale_id-ID.ini => gitea_id-ID.ini} (100%) rename options/locale/{locale_is-IS.ini => gitea_is-IS.ini} (100%) rename options/locale/{locale_it-IT.ini => gitea_it-IT.ini} (100%) rename options/locale/{locale_ja-JP.ini => gitea_ja-JP.ini} (100%) rename options/locale/{locale_ko-KR.ini => gitea_ko-KR.ini} (100%) rename options/locale/{locale_lv-LV.ini => gitea_lv-LV.ini} (100%) rename options/locale/{locale_nl-NL.ini => gitea_nl-NL.ini} (100%) rename options/locale/{locale_pl-PL.ini => gitea_pl-PL.ini} (100%) rename options/locale/{locale_pt-BR.ini => gitea_pt-BR.ini} (100%) rename options/locale/{locale_pt-PT.ini => gitea_pt-PT.ini} (100%) rename options/locale/{locale_ru-RU.ini => gitea_ru-RU.ini} (100%) rename options/locale/{locale_si-LK.ini => gitea_si-LK.ini} (100%) rename options/locale/{locale_sk-SK.ini => gitea_sk-SK.ini} (100%) rename options/locale/{locale_sv-SE.ini => gitea_sv-SE.ini} (100%) rename options/locale/{locale_tr-TR.ini => gitea_tr-TR.ini} (100%) rename options/locale/{locale_uk-UA.ini => gitea_uk-UA.ini} (100%) rename options/locale/{locale_zh-CN.ini => gitea_zh-CN.ini} (100%) rename options/locale/{locale_zh-HK.ini => gitea_zh-HK.ini} (100%) rename options/locale/{locale_zh-TW.ini => gitea_zh-TW.ini} (100%) diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/gitea_cs-CZ.ini similarity index 100% rename from options/locale/locale_cs-CZ.ini rename to options/locale/gitea_cs-CZ.ini diff --git a/options/locale/locale_de-DE.ini b/options/locale/gitea_de-DE.ini similarity index 100% rename from options/locale/locale_de-DE.ini rename to options/locale/gitea_de-DE.ini diff --git a/options/locale/locale_el-GR.ini b/options/locale/gitea_el-GR.ini similarity index 100% rename from options/locale/locale_el-GR.ini rename to options/locale/gitea_el-GR.ini diff --git a/options/locale/locale_en-US.ini b/options/locale/gitea_en-US.ini similarity index 100% rename from options/locale/locale_en-US.ini rename to options/locale/gitea_en-US.ini diff --git a/options/locale/locale_es-ES.ini b/options/locale/gitea_es-ES.ini similarity index 100% rename from options/locale/locale_es-ES.ini rename to options/locale/gitea_es-ES.ini diff --git a/options/locale/locale_fa-IR.ini b/options/locale/gitea_fa-IR.ini similarity index 100% rename from options/locale/locale_fa-IR.ini rename to options/locale/gitea_fa-IR.ini diff --git a/options/locale/locale_fi-FI.ini b/options/locale/gitea_fi-FI.ini similarity index 100% rename from options/locale/locale_fi-FI.ini rename to options/locale/gitea_fi-FI.ini diff --git a/options/locale/locale_fr-FR.ini b/options/locale/gitea_fr-FR.ini similarity index 100% rename from options/locale/locale_fr-FR.ini rename to options/locale/gitea_fr-FR.ini diff --git a/options/locale/locale_hu-HU.ini b/options/locale/gitea_hu-HU.ini similarity index 100% rename from options/locale/locale_hu-HU.ini rename to options/locale/gitea_hu-HU.ini diff --git a/options/locale/locale_id-ID.ini b/options/locale/gitea_id-ID.ini similarity index 100% rename from options/locale/locale_id-ID.ini rename to options/locale/gitea_id-ID.ini diff --git a/options/locale/locale_is-IS.ini b/options/locale/gitea_is-IS.ini similarity index 100% rename from options/locale/locale_is-IS.ini rename to options/locale/gitea_is-IS.ini diff --git a/options/locale/locale_it-IT.ini b/options/locale/gitea_it-IT.ini similarity index 100% rename from options/locale/locale_it-IT.ini rename to options/locale/gitea_it-IT.ini diff --git a/options/locale/locale_ja-JP.ini b/options/locale/gitea_ja-JP.ini similarity index 100% rename from options/locale/locale_ja-JP.ini rename to options/locale/gitea_ja-JP.ini diff --git a/options/locale/locale_ko-KR.ini b/options/locale/gitea_ko-KR.ini similarity index 100% rename from options/locale/locale_ko-KR.ini rename to options/locale/gitea_ko-KR.ini diff --git a/options/locale/locale_lv-LV.ini b/options/locale/gitea_lv-LV.ini similarity index 100% rename from options/locale/locale_lv-LV.ini rename to options/locale/gitea_lv-LV.ini diff --git a/options/locale/locale_nl-NL.ini b/options/locale/gitea_nl-NL.ini similarity index 100% rename from options/locale/locale_nl-NL.ini rename to options/locale/gitea_nl-NL.ini diff --git a/options/locale/locale_pl-PL.ini b/options/locale/gitea_pl-PL.ini similarity index 100% rename from options/locale/locale_pl-PL.ini rename to options/locale/gitea_pl-PL.ini diff --git a/options/locale/locale_pt-BR.ini b/options/locale/gitea_pt-BR.ini similarity index 100% rename from options/locale/locale_pt-BR.ini rename to options/locale/gitea_pt-BR.ini diff --git a/options/locale/locale_pt-PT.ini b/options/locale/gitea_pt-PT.ini similarity index 100% rename from options/locale/locale_pt-PT.ini rename to options/locale/gitea_pt-PT.ini diff --git a/options/locale/locale_ru-RU.ini b/options/locale/gitea_ru-RU.ini similarity index 100% rename from options/locale/locale_ru-RU.ini rename to options/locale/gitea_ru-RU.ini diff --git a/options/locale/locale_si-LK.ini b/options/locale/gitea_si-LK.ini similarity index 100% rename from options/locale/locale_si-LK.ini rename to options/locale/gitea_si-LK.ini diff --git a/options/locale/locale_sk-SK.ini b/options/locale/gitea_sk-SK.ini similarity index 100% rename from options/locale/locale_sk-SK.ini rename to options/locale/gitea_sk-SK.ini diff --git a/options/locale/locale_sv-SE.ini b/options/locale/gitea_sv-SE.ini similarity index 100% rename from options/locale/locale_sv-SE.ini rename to options/locale/gitea_sv-SE.ini diff --git a/options/locale/locale_tr-TR.ini b/options/locale/gitea_tr-TR.ini similarity index 100% rename from options/locale/locale_tr-TR.ini rename to options/locale/gitea_tr-TR.ini diff --git a/options/locale/locale_uk-UA.ini b/options/locale/gitea_uk-UA.ini similarity index 100% rename from options/locale/locale_uk-UA.ini rename to options/locale/gitea_uk-UA.ini diff --git a/options/locale/locale_zh-CN.ini b/options/locale/gitea_zh-CN.ini similarity index 100% rename from options/locale/locale_zh-CN.ini rename to options/locale/gitea_zh-CN.ini diff --git a/options/locale/locale_zh-HK.ini b/options/locale/gitea_zh-HK.ini similarity index 100% rename from options/locale/locale_zh-HK.ini rename to options/locale/gitea_zh-HK.ini diff --git a/options/locale/locale_zh-TW.ini b/options/locale/gitea_zh-TW.ini similarity index 100% rename from options/locale/locale_zh-TW.ini rename to options/locale/gitea_zh-TW.ini From 987425d6de93a1bad0a19385f8eed48fd2c5fa5f Mon Sep 17 00:00:00 2001 From: fnetx Date: Wed, 14 Dec 2022 19:55:13 +0100 Subject: [PATCH 2/4] [I18N] Add Locale merger script (cherry picked from commit ecc3dae2acaf567cd6b2888cc5c582588c7bfc53) (cherry picked from commit c6c3fc6ace6b6aa4f4877c5a96da54899f2dc2fa) (cherry picked from commit 4833bd594a49b70896c023b41da8a87ba33add0e) [I18N] in the home page replace GitHub with Forgejo The english string that shows on the home page to encourage for contribution no longer reference GitHub. But some translations still do. In this context, and this context only, replace it with Forgejo even though it may not be correct in some cases. Refs: https://codeberg.org/forgejo/forgejo/pulls/450 (cherry picked from commit 71de77f5ae59617eadda9e4992f1867a7acb7f17) (cherry picked from commit 0b5195e4e4ee1c4829d7f4e127cc48d5c0eb3d72) (cherry picked from commit 1252e83f8c7b22e06bb37622900741caa209e9eb) (cherry picked from commit 2ceb1b2b5faa32ca71716ed4c98d18b0942909e7) (cherry picked from commit 59233055b1a8e9bc79c5501d6e2c2649a6d1b26b) (cherry picked from commit 378ed6a21e0a57c3bb5211eb8ade4db499cdd7d9) (cherry picked from commit 2d661119c3b8a8278458005273f6a32fa3216050) (cherry picked from commit 2a95ff4107786bbf6c5b141a42e2efbd1bb897f8) (cherry picked from commit 012b5444a80cf2aaa61b2b65efebfe0691725422) (cherry picked from commit 2aaee4f7c4132af6f9a6e0d9aafe0218603b8a5c) (cherry picked from commit 52b3f53cb7dfc86a1287baa40f5f5b6dce946a27) (cherry picked from commit 24e665abe748ff34163e7c870aa0b90ffca86c26) (cherry picked from commit 335f8b2bd1971ce3b39b57b2cfd6d8c9af85ab75) (cherry picked from commit da3890938b7a13a467520fccfa6187376eab3050) (cherry picked from commit 5d0cdd5fe228906d378152b2472f7399fa9e3c45) (cherry picked from commit ed8e299b59e903f025cbbae8769e10678372b4b8) (cherry picked from commit b38db49888a6f627ab6c440899c0f6ccc3d55979) (cherry picked from commit c19cb35acf947153458707d8431153b8f3de0cf1) (cherry picked from commit 45fc0e2dda954d57adab7c3fc261c4e89e9f010d) (cherry picked from commit e7ef7c26d1883977684cf2ab576743c3d4f2f19e) (cherry picked from commit 11d05b0dc5b4dac8b2f6bad6e1f02e32d93f1704) (cherry picked from commit 8f7287337e7f316191c78aff01fddb3fc04ba2bb) (cherry picked from commit 8351803ee197a18d1faf84765ce55ed9b7498f9b) (cherry picked from commit 0ebf3c0fc73577e4a6fc379efb0164836943644b) (cherry picked from commit 749d3b4f68db8fc6d1eca61d6b0eeb3b40b20e63) Replaced gitea links with forgejo - protected tags, webhooks (cherry picked from commit 12534649d06af0ac518714dc28916ccc08a5a87c) (cherry picked from commit 5ad3ff69d41502dd8b3ac5cd30729353683c4316) (cherry picked from commit a7a325b3f5de8fca6be552e0c98a5125858a8e0a) (cherry picked from commit 31d2cc455f5339fc78de08237b49e4c6200a27e9) (cherry picked from commit 99b71abfdb4a000f1081fca988bc5295cca18473) (cherry picked from commit b096317ac9a2436e5c1563c44c5aee4be6dd2f5d) (cherry picked from commit cbc5cfdfd690278a17f034c2b00d4b48cafba977) (cherry picked from commit 1c99fa3f709e2ffce36c135d098971152154b7b4) (cherry picked from commit abf26758f4c09fb411d35a7494eddc675b9ba154) (cherry picked from commit ccf53ef1d693bf26d4d12955e2543683d1f81654) (cherry picked from commit 9287916ac8f1a492a6d65a0c46135a6c180db7a6) (cherry picked from commit 1f646e43ef6713bdfa233f93b294c4656e62428d) (cherry picked from commit 162873dff6517dbf6857d102479e1d2f73d51015) (cherry picked from commit c41533138d6ea9bdc7b3fb196eb8b1b3827550ed) (cherry picked from commit 6bd8b1aa61204cc6bc0f2ae09cbfbe9754ab4085) (cherry picked from commit fc2decb959854690c0bbeb08e6648d62a72d8da6) [I18N] Add Locale merger script (squash) abort on NOOP If a string is no longer used in the english version of the locales, it means the Gitea string was changed and it needs updating. Abort when it is the case and recommend action. (cherry picked from commit 34f3d7d65e982b729bb878dde04c8a1093885ed6) (cherry picked from commit 666aa258adcfd16276763f32ab1b58b9e817efcc) (cherry picked from commit f9655eebeb56d28abc3b576ceb828c76fc8c73f4) (cherry picked from commit f6979b0aacdda5d3295cb9f4d8a045ebd9abdfb2) (cherry picked from commit c3c62bea76c87b45fb709a0bef144e3a971e763a) (cherry picked from commit d69cab8b95e57b4709f515acf9ee3226b2833f3e) (cherry picked from commit 521184d6a6887a8b48a4266ebe480e246c51eb18) --- build/merge-forgejo-locales.go | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 build/merge-forgejo-locales.go diff --git a/build/merge-forgejo-locales.go b/build/merge-forgejo-locales.go new file mode 100644 index 0000000000..3fecde12e2 --- /dev/null +++ b/build/merge-forgejo-locales.go @@ -0,0 +1,117 @@ +// 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" + "log" + "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) + } + + replacements := []string{ + "Gitea", "Forgejo", + "https://docs.gitea.com/installation/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.com/installation/install-from-package", "https://forgejo.org/download", + "https://code.gitea.io/gitea", "https://forgejo.org/download", + "code.gitea.io/gitea", "Forgejo", + `GitHub`, `Codeberg`, + "https://github.com/go-gitea/gitea", "https://codeberg.org/forgejo/forgejo", + "https://blog.gitea.io", "https://forgejo.org/news", + "https://docs.gitea.com/usage/protected-tags", "https://forgejo.org/docs/latest/user/protection/#protected-tags", + "https://docs.gitea.com/usage/webhooks", "https://forgejo.org/docs/latest/user/webhooks/", + } + replacer := strings.NewReplacer(replacements...) + replaced := make(map[string]bool, len(replacements)/2) + count_replaced := func(original string) { + for i := 0; i < len(replacements); i += 2 { + if strings.Contains(original, replacements[i]) { + replaced[replacements[i]] = true + } + } + } + + 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 { + count_replaced(line) + out = append(out, []byte(replacer.Replace(line)+"\n")...) + } + } + file.Close() + if strings.HasSuffix(filename, "gitea_en-US.ini") { + for i := 0; i < len(replacements); i += 2 { + if replaced[replacements[i]] == false { + log.Fatalf("%s was never used to replace something in %s, it is obsolete and must be updated", replacements[i], filename) + } + } + } + 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) + } + } +} From cd86ad60e688726139dd496ffb66048848a840e0 Mon Sep 17 00:00:00 2001 From: fnetx Date: Wed, 14 Dec 2022 19:56:57 +0100 Subject: [PATCH 3/4] [I18N] Makefile + gitignore (cherry picked from commit 68c744111d02a0cd93716a8f75442ad85f44243b) (cherry picked from commit 30d7c4a8998baf957b8a156789cc6601d4e87628) (cherry picked from commit 220ac0a6d3579da5d9c1a028cdd59511f3e97a88) (cherry picked from commit 21cb16af9502c0c14aae30eee3a65d4c14be3cbe) (cherry picked from commit 41a9373e3e78f050bb07ea475fdbf3261cf694b2) (cherry picked from commit 69030f7803c175706946af5fb8956d19aa7d2bec) (cherry picked from commit 92c4d4d2e6bf7f100feb5c85a9ae78afea2adbd8) (cherry picked from commit c1bfd1730e79c6c1720df99f367ddc030282f7e3) (cherry picked from commit 18a9a9e73cdea5bd501b10a2fde0d39be74d7f25) (cherry picked from commit 07f988207303011b3f645dc515ff855c0317507f) (cherry picked from commit e71b8061d4297fe2336cbf404046c1fdd8332fc6) (cherry picked from commit 225b30f1f77cd5edd06ca4a271a64029b0391d7e) (cherry picked from commit fdf98910039a98009e3c38be00db1785fe4292e7) (cherry picked from commit df2f4134764a4811a4f012193b93b2d1b8a2749b) (cherry picked from commit b01c755aaf634dd0f4c436ad90eda47f6e901afd) (cherry picked from commit acd4275acbada93b49c0baabfc5bd9db2ebbca6c) [I18N] Add Locale merger script (squash: compile on windows) Fixes: https://codeberg.org/forgejo/forgejo/issues/798 (cherry picked from commit b47b205e85f115b2493bd4c3a25c199196228d7a) (cherry picked from commit 1521f0bfd6747d0ad0d9c5e70c4c0b1d948e178e) (cherry picked from commit 7f988de42c6934105399985c7dd652ce81b79b3f) (cherry picked from commit d26b4913129e13c3afde69cd6c6db948e7789e3e) (cherry picked from commit 60136bac666f588179dbe1a9d98df0f82fcfb7de) (cherry picked from commit 915bb4b3542b14cc5f0e4d9feb3b8fa55a6d8440) (cherry picked from commit 3e1b42a8ca84a6abb81d4dfaf84ea7be383e7a37) (cherry picked from commit 18d8fc075fa6002fc1af0374005801cdeffc185d) (cherry picked from commit 1d9f95687b395df973e19d97294fca16b6f233e6) (cherry picked from commit e49da1a90d2358f18510d8e2e45448b24386f34e) (cherry picked from commit a182baed8a6a139dc473aa74797cdc404c206a72) (cherry picked from commit 3e48a87c0044b38dc8a9594c0dd14921a40f7e0b) (cherry picked from commit e0bb406c146408739f3140182082e910ac5b874c) (cherry picked from commit e45ec160f95f35a156423f98d7e8b0479184e197) (cherry picked from commit e89ec6d0086aedd0fddc2ee282b7a0f2c87b917a) (cherry picked from commit 80eb392c5c2c6e6decb7f99873c3dc7d6b300dd6) (cherry picked from commit d0bce1b613ab2c72c960f1e982b5cf7d60a7dfb2) (cherry picked from commit 8debcf86ea78cfb0e93eb720fb57f18641f1f65f) (cherry picked from commit a9bc3c54d721dbec8df640ba80f85cf0bfd5b36a) (cherry picked from commit d5595e4156cb7a613c1ff3cf28bfbfefa6678fd0) (cherry picked from commit 25cef0fad366af2faf5687fa95d445b43d28215d) (cherry picked from commit e4d15446ff34b2e9b624f3a8c6bdb9930e1b9b37) (cherry picked from commit 77ceb2a795bce2797f819960103b59f22e9bba4d) (cherry picked from commit 61ebe5c5365fb6df6cfcfd4f24e6309e6fa39707) (cherry picked from commit 9377e1d1f25f773123abdf1b1665b765b2c503dd) (cherry picked from commit 7a90ba2922d9250adcbebffaf26d773805895e64) (cherry picked from commit bc65d42a836c16936e8327d47e8d20edd5d1ca3d) (cherry picked from commit 333f486015c8a05389c4aa70a23225f3719e5d43) (cherry picked from commit 0e90edaf12a2fc1241fb02cf398a0c8d316f6d7b) (cherry picked from commit 511d797ffbd4ef505d243bbb1c2cfba0d39a8b3f) (cherry picked from commit 2515b655ab6c7aa9fbb7a37023b1c77774e4a88e) --- .gitignore | 3 +++ Makefile | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 12014d405b..4ec16917d6 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,6 @@ prime/ # Manpage /man + +# Generated merged Forgejo+Gitea language files +/options/locale/locale_* diff --git a/Makefile b/Makefile index d9582737ec..a504cbf648 100644 --- a/Makefile +++ b/Makefile @@ -796,10 +796,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: + @CC= GOOS= GOARCH= $(GO) run build/merge-forgejo-locales.go + .PHONY: security-check security-check: go run $(GOVULNCHECK_PACKAGE) ./... @@ -972,13 +976,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: From 1d9844bbb3d456c47380463ccc9156e89b4878b1 Mon Sep 17 00:00:00 2001 From: fnetx Date: Thu, 15 Dec 2022 15:56:35 +0100 Subject: [PATCH 4/4] [I18N] Move source locales to other folder (cherry picked from commit d38ad85a05cb3547ad1c3f90531811aa9c78ca9d) (cherry picked from commit b94f9b8c1bdc62d7437c42c4aa333c7ed30a9b9b) (cherry picked from commit c728ce8b32b0ff52e14083d2118f6b1f233307ce) (cherry picked from commit 2911286336f93bbf6a6dec63cf62cb1514475eff) (cherry picked from commit bd4dc797c7cc599d2aca05b7d1ee2a6532dd0358) (cherry picked from commit 35889addf9ee26e084ff2f525e5fb078b5d261bd) (cherry picked from commit 9eaf321db44b70613e9f10e32f8e8628bd720610) (cherry picked from commit 7b64ef0c9b4dc1add73d91e126388cb835a3f472) (cherry picked from commit 6cd86bf244a29b888eb0218061aa95ee75ced790) (cherry picked from commit 275dd36f580c9553bc78dd1b7afb672c51e35e9f) (cherry picked from commit d5ace5a0ae27ad7c30ee5fff0f821cab4144979c) (cherry picked from commit c067466f8c28229228ae185267e228d552bb38e3) (cherry picked from commit 0d51a2228fe85c5ab097475987c4faf411df4658) (cherry picked from commit 4973e19dd3b043ce6de2a33d36dadbf4155a0075) (cherry picked from commit f553b4d54385439e3496a7890182b2a70d84a42d) (cherry picked from commit 18312a6f74f664021df7e3beb373ef1e368198ac) (cherry picked from commit d09dc97f8bdee6279ac9e47d4d45d241f9522251) (cherry picked from commit 10c552e54ed92bf7f68f64b202585a481780bada) (cherry picked from commit edf895e866469a3765a2b8cd6bbbd2cdd8c185a8) (cherry picked from commit 786a486cfcb481844b75da2ccfddf5853fc22486) (cherry picked from commit 2aa16d5cb9255693c8d2e7cdef854b75e2f7d499) (cherry picked from commit 1e940cf6cd3f6c64f7ff214b5dc8693b39854ecd) (cherry picked from commit 7355f3a65350ca325937d1ca715ac997ffb52c95) (cherry picked from commit e630328f5fad88b570e0e89f57183d436d856ce5) (cherry picked from commit 4f819cb97c74f727c6556979ab1826107697589a) (cherry picked from commit 3ffdabd3edd6775641c3989f7366a04bc2a9183f) (cherry picked from commit df4fb86007c29d08196c545b1b6f7eb77f1cd3ef) (cherry picked from commit 3826909cbb98e3e107b6fae06b4ad3369510286f) (cherry picked from commit d9825f7165e8e7cd025eb402df15f5f9d5a2bdc4) (cherry picked from commit 78ce758e6090ad2bfb5c9af1a591af9e086727da) (cherry picked from commit e94fb8986b6941ef0f1b203785571f4999242284) (cherry picked from commit 55043c590c9e4ce2131bd7f0be00c52689223431) (cherry picked from commit 432885ecc61783940a7da7a956017a5ab09a2a42) (cherry picked from commit 1f923c92f22a38063edd797a491a1ff109411805) (cherry picked from commit 3757f133877b9d3236e0516fb357476aa382eff2) (cherry picked from commit 2aae06ea3ec249d9ac0844bc7824daca617e5ffa) (cherry picked from commit 1eaa3095ce26a37b4a3c29d1cb742945b5b7ad91) (cherry picked from commit 16d95a8b66e84e28e5b917189ddedfcf837dc2ce) (cherry picked from commit c1b4608baa4977cbd21f9c84e9e45dea0b9821f6) (cherry picked from commit 1b3c486a8828e598da53374d5b1ea832d6b8b1fb) (cherry picked from commit 71375cb3cf4c18618bbe91aab1d8f2402f10c999) (cherry picked from commit 652902bf1f937d9eaf8f3694b671cdf798f1d449) (cherry picked from commit d09278409b10a3ab27a54c1426c49154e086384b) (cherry picked from commit ba38187b1202d56a148788fd810c17e76978566c) (cherry picked from commit 5a906e54d96cdbdc46db3e48b4b713f5105397f9) (cherry picked from commit d8a492750012a1364353419f7ef3e9138f8fc9cb) --- options/{locale => locales}/gitea_cs-CZ.ini | 0 options/{locale => locales}/gitea_de-DE.ini | 0 options/{locale => locales}/gitea_el-GR.ini | 0 options/{locale => locales}/gitea_en-US.ini | 0 options/{locale => locales}/gitea_es-ES.ini | 0 options/{locale => locales}/gitea_fa-IR.ini | 0 options/{locale => locales}/gitea_fi-FI.ini | 0 options/{locale => locales}/gitea_fr-FR.ini | 0 options/{locale => locales}/gitea_hu-HU.ini | 0 options/{locale => locales}/gitea_id-ID.ini | 0 options/{locale => locales}/gitea_is-IS.ini | 0 options/{locale => locales}/gitea_it-IT.ini | 0 options/{locale => locales}/gitea_ja-JP.ini | 0 options/{locale => locales}/gitea_ko-KR.ini | 0 options/{locale => locales}/gitea_lv-LV.ini | 0 options/{locale => locales}/gitea_nl-NL.ini | 0 options/{locale => locales}/gitea_pl-PL.ini | 0 options/{locale => locales}/gitea_pt-BR.ini | 0 options/{locale => locales}/gitea_pt-PT.ini | 0 options/{locale => locales}/gitea_ru-RU.ini | 0 options/{locale => locales}/gitea_si-LK.ini | 0 options/{locale => locales}/gitea_sk-SK.ini | 0 options/{locale => locales}/gitea_sv-SE.ini | 0 options/{locale => locales}/gitea_tr-TR.ini | 0 options/{locale => locales}/gitea_uk-UA.ini | 0 options/{locale => locales}/gitea_zh-CN.ini | 0 options/{locale => locales}/gitea_zh-HK.ini | 0 options/{locale => locales}/gitea_zh-TW.ini | 0 28 files changed, 0 insertions(+), 0 deletions(-) rename options/{locale => locales}/gitea_cs-CZ.ini (100%) rename options/{locale => locales}/gitea_de-DE.ini (100%) rename options/{locale => locales}/gitea_el-GR.ini (100%) rename options/{locale => locales}/gitea_en-US.ini (100%) rename options/{locale => locales}/gitea_es-ES.ini (100%) rename options/{locale => locales}/gitea_fa-IR.ini (100%) rename options/{locale => locales}/gitea_fi-FI.ini (100%) rename options/{locale => locales}/gitea_fr-FR.ini (100%) rename options/{locale => locales}/gitea_hu-HU.ini (100%) rename options/{locale => locales}/gitea_id-ID.ini (100%) rename options/{locale => locales}/gitea_is-IS.ini (100%) rename options/{locale => locales}/gitea_it-IT.ini (100%) rename options/{locale => locales}/gitea_ja-JP.ini (100%) rename options/{locale => locales}/gitea_ko-KR.ini (100%) rename options/{locale => locales}/gitea_lv-LV.ini (100%) rename options/{locale => locales}/gitea_nl-NL.ini (100%) rename options/{locale => locales}/gitea_pl-PL.ini (100%) rename options/{locale => locales}/gitea_pt-BR.ini (100%) rename options/{locale => locales}/gitea_pt-PT.ini (100%) rename options/{locale => locales}/gitea_ru-RU.ini (100%) rename options/{locale => locales}/gitea_si-LK.ini (100%) rename options/{locale => locales}/gitea_sk-SK.ini (100%) rename options/{locale => locales}/gitea_sv-SE.ini (100%) rename options/{locale => locales}/gitea_tr-TR.ini (100%) rename options/{locale => locales}/gitea_uk-UA.ini (100%) rename options/{locale => locales}/gitea_zh-CN.ini (100%) rename options/{locale => locales}/gitea_zh-HK.ini (100%) rename options/{locale => locales}/gitea_zh-TW.ini (100%) diff --git a/options/locale/gitea_cs-CZ.ini b/options/locales/gitea_cs-CZ.ini similarity index 100% rename from options/locale/gitea_cs-CZ.ini rename to options/locales/gitea_cs-CZ.ini diff --git a/options/locale/gitea_de-DE.ini b/options/locales/gitea_de-DE.ini similarity index 100% rename from options/locale/gitea_de-DE.ini rename to options/locales/gitea_de-DE.ini diff --git a/options/locale/gitea_el-GR.ini b/options/locales/gitea_el-GR.ini similarity index 100% rename from options/locale/gitea_el-GR.ini rename to options/locales/gitea_el-GR.ini diff --git a/options/locale/gitea_en-US.ini b/options/locales/gitea_en-US.ini similarity index 100% rename from options/locale/gitea_en-US.ini rename to options/locales/gitea_en-US.ini diff --git a/options/locale/gitea_es-ES.ini b/options/locales/gitea_es-ES.ini similarity index 100% rename from options/locale/gitea_es-ES.ini rename to options/locales/gitea_es-ES.ini diff --git a/options/locale/gitea_fa-IR.ini b/options/locales/gitea_fa-IR.ini similarity index 100% rename from options/locale/gitea_fa-IR.ini rename to options/locales/gitea_fa-IR.ini diff --git a/options/locale/gitea_fi-FI.ini b/options/locales/gitea_fi-FI.ini similarity index 100% rename from options/locale/gitea_fi-FI.ini rename to options/locales/gitea_fi-FI.ini diff --git a/options/locale/gitea_fr-FR.ini b/options/locales/gitea_fr-FR.ini similarity index 100% rename from options/locale/gitea_fr-FR.ini rename to options/locales/gitea_fr-FR.ini diff --git a/options/locale/gitea_hu-HU.ini b/options/locales/gitea_hu-HU.ini similarity index 100% rename from options/locale/gitea_hu-HU.ini rename to options/locales/gitea_hu-HU.ini diff --git a/options/locale/gitea_id-ID.ini b/options/locales/gitea_id-ID.ini similarity index 100% rename from options/locale/gitea_id-ID.ini rename to options/locales/gitea_id-ID.ini diff --git a/options/locale/gitea_is-IS.ini b/options/locales/gitea_is-IS.ini similarity index 100% rename from options/locale/gitea_is-IS.ini rename to options/locales/gitea_is-IS.ini diff --git a/options/locale/gitea_it-IT.ini b/options/locales/gitea_it-IT.ini similarity index 100% rename from options/locale/gitea_it-IT.ini rename to options/locales/gitea_it-IT.ini diff --git a/options/locale/gitea_ja-JP.ini b/options/locales/gitea_ja-JP.ini similarity index 100% rename from options/locale/gitea_ja-JP.ini rename to options/locales/gitea_ja-JP.ini diff --git a/options/locale/gitea_ko-KR.ini b/options/locales/gitea_ko-KR.ini similarity index 100% rename from options/locale/gitea_ko-KR.ini rename to options/locales/gitea_ko-KR.ini diff --git a/options/locale/gitea_lv-LV.ini b/options/locales/gitea_lv-LV.ini similarity index 100% rename from options/locale/gitea_lv-LV.ini rename to options/locales/gitea_lv-LV.ini diff --git a/options/locale/gitea_nl-NL.ini b/options/locales/gitea_nl-NL.ini similarity index 100% rename from options/locale/gitea_nl-NL.ini rename to options/locales/gitea_nl-NL.ini diff --git a/options/locale/gitea_pl-PL.ini b/options/locales/gitea_pl-PL.ini similarity index 100% rename from options/locale/gitea_pl-PL.ini rename to options/locales/gitea_pl-PL.ini diff --git a/options/locale/gitea_pt-BR.ini b/options/locales/gitea_pt-BR.ini similarity index 100% rename from options/locale/gitea_pt-BR.ini rename to options/locales/gitea_pt-BR.ini diff --git a/options/locale/gitea_pt-PT.ini b/options/locales/gitea_pt-PT.ini similarity index 100% rename from options/locale/gitea_pt-PT.ini rename to options/locales/gitea_pt-PT.ini diff --git a/options/locale/gitea_ru-RU.ini b/options/locales/gitea_ru-RU.ini similarity index 100% rename from options/locale/gitea_ru-RU.ini rename to options/locales/gitea_ru-RU.ini diff --git a/options/locale/gitea_si-LK.ini b/options/locales/gitea_si-LK.ini similarity index 100% rename from options/locale/gitea_si-LK.ini rename to options/locales/gitea_si-LK.ini diff --git a/options/locale/gitea_sk-SK.ini b/options/locales/gitea_sk-SK.ini similarity index 100% rename from options/locale/gitea_sk-SK.ini rename to options/locales/gitea_sk-SK.ini diff --git a/options/locale/gitea_sv-SE.ini b/options/locales/gitea_sv-SE.ini similarity index 100% rename from options/locale/gitea_sv-SE.ini rename to options/locales/gitea_sv-SE.ini diff --git a/options/locale/gitea_tr-TR.ini b/options/locales/gitea_tr-TR.ini similarity index 100% rename from options/locale/gitea_tr-TR.ini rename to options/locales/gitea_tr-TR.ini diff --git a/options/locale/gitea_uk-UA.ini b/options/locales/gitea_uk-UA.ini similarity index 100% rename from options/locale/gitea_uk-UA.ini rename to options/locales/gitea_uk-UA.ini diff --git a/options/locale/gitea_zh-CN.ini b/options/locales/gitea_zh-CN.ini similarity index 100% rename from options/locale/gitea_zh-CN.ini rename to options/locales/gitea_zh-CN.ini diff --git a/options/locale/gitea_zh-HK.ini b/options/locales/gitea_zh-HK.ini similarity index 100% rename from options/locale/gitea_zh-HK.ini rename to options/locales/gitea_zh-HK.ini diff --git a/options/locale/gitea_zh-TW.ini b/options/locales/gitea_zh-TW.ini similarity index 100% rename from options/locale/gitea_zh-TW.ini rename to options/locales/gitea_zh-TW.ini