WIP: feat: translation support
Some checks failed
continuous-integration/drone/push Build is failing

See #483
This commit is contained in:
2025-08-19 11:22:52 +02:00
parent 5cf6048ecb
commit 57e09b6917
108 changed files with 11210 additions and 1645 deletions

View File

@ -2,11 +2,13 @@ package git
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"strings"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
@ -44,7 +46,7 @@ func Clone(dir, url string) error {
go func() {
if _, err := os.Stat(dir); os.IsNotExist(err) {
log.Debugf("git clone: %s", url)
log.Debug(i18n.G("git clone: %s", url))
_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
URL: url,
@ -54,16 +56,16 @@ func Clone(dir, url string) error {
})
if err != nil && gitCloneIgnoreErr(err) {
log.Debugf("git clone: %s cloned successfully", dir)
log.Debug(i18n.G("git clone: %s cloned successfully", dir))
errCh <- nil
}
if err := ctx.Err(); err != nil {
errCh <- fmt.Errorf("git clone %s: cancelled due to interrupt", dir)
errCh <- errors.New(i18n.G("git clone %s: cancelled due to interrupt", dir))
}
if err != nil {
log.Debug("git clone: main branch failed, attempting master branch")
log.Debug(i18n.G("git clone: main branch failed, attempting master branch"))
_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
URL: url,
@ -73,7 +75,7 @@ func Clone(dir, url string) error {
})
if err != nil && gitCloneIgnoreErr(err) {
log.Debugf("git clone: %s cloned successfully", dir)
log.Debug(i18n.G("git clone: %s cloned successfully", dir))
errCh <- nil
}
@ -82,9 +84,9 @@ func Clone(dir, url string) error {
}
}
log.Debugf("git clone: %s cloned successfully", dir)
log.Debug(i18n.G("git clone: %s cloned successfully", dir))
} else {
log.Debugf("git clone: %s already exists", dir)
log.Debug(i18n.G("git clone: %s already exists", dir))
}
errCh <- nil
@ -95,9 +97,9 @@ func Clone(dir, url string) error {
cancelCtx()
fmt.Println() // NOTE(d1): newline after ^C
if err := os.RemoveAll(dir); err != nil {
return fmt.Errorf("unable to clean up git clone of %s: %s", dir, err)
return errors.New(i18n.G("unable to clean up git clone of %s: %s", dir, err))
}
return fmt.Errorf("git clone %s: cancelled due to interrupt", dir)
return errors.New(i18n.G("git clone %s: cancelled due to interrupt", dir))
case err := <-errCh:
return err
}