summaryrefslogtreecommitdiffstats
path: root/build/backport-locales.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-06-02 11:27:30 +0200
committerGitHub <noreply@github.com>2023-06-02 11:27:30 +0200
commitde4a21fcb4476772c69c36d086549e89ed4dcf6c (patch)
treea8952b92bc6382daffc34178f5d6cc32cfea2efd /build/backport-locales.go
parent[skip ci] Updated translations via Crowdin (diff)
downloadforgejo-de4a21fcb4476772c69c36d086549e89ed4dcf6c.tar.xz
forgejo-de4a21fcb4476772c69c36d086549e89ed4dcf6c.zip
Refactor INI package (first step) (#25024)
The INI package has many bugs and quirks, and in fact it is unmaintained. This PR is the first step for the INI package refactoring: * Use Gitea's "config_provider" to provide INI access * Deprecate the INI package by golangci.yml rule
Diffstat (limited to 'build/backport-locales.go')
-rw-r--r--build/backport-locales.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/build/backport-locales.go b/build/backport-locales.go
index 054b623d69..0346215348 100644
--- a/build/backport-locales.go
+++ b/build/backport-locales.go
@@ -12,7 +12,7 @@ import (
"path/filepath"
"strings"
- "gopkg.in/ini.v1"
+ "code.gitea.io/gitea/modules/setting"
)
func main() {
@@ -22,14 +22,13 @@ func main() {
os.Exit(1)
}
- ini.PrettyFormat = false
mustNoErr := func(err error) {
if err != nil {
panic(err)
}
}
- collectInis := func(ref string) map[string]*ini.File {
- inis := map[string]*ini.File{}
+ collectInis := func(ref string) map[string]setting.ConfigProvider {
+ inis := map[string]setting.ConfigProvider{}
err := filepath.WalkDir("options/locale", func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
@@ -37,10 +36,7 @@ func main() {
if d.IsDir() || !strings.HasSuffix(d.Name(), ".ini") {
return nil
}
- cfg, err := ini.LoadSources(ini.LoadOptions{
- IgnoreInlineComment: true,
- UnescapeValueCommentSymbols: true,
- }, path)
+ cfg, err := setting.NewConfigProviderForLocale(path)
mustNoErr(err)
inis[path] = cfg
fmt.Printf("collecting: %s @ %s\n", path, ref)