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 a31ec51c24
71 changed files with 804 additions and 796 deletions

View File

@ -1,7 +1,7 @@
package config
import (
"fmt"
"errors"
"io/fs"
"io/ioutil"
"os"
@ -10,6 +10,7 @@ import (
"strings"
"coopcloud.tech/abra/pkg/log"
"github.com/leonelquinteros/gotext"
)
const MAX_SANITISED_APP_NAME_LENGTH = 45
@ -33,7 +34,7 @@ func GetServers() ([]string, error) {
}
}
log.Debugf("retrieved %v servers: %s", len(filtered), filtered)
log.Debug(gotext.Get("retrieved %v servers: %s", len(filtered), filtered))
return filtered, nil
}
@ -46,7 +47,7 @@ func ReadServerNames() ([]string, error) {
return nil, err
}
log.Debugf("read %s from %s", strings.Join(serverNames, ","), SERVERS_DIR)
log.Debug(gotext.Get("read %s from %s", strings.Join(serverNames, ","), SERVERS_DIR))
return serverNames, nil
}
@ -70,7 +71,7 @@ func GetAllFilesInDirectory(directory string) ([]fs.FileInfo, error) {
realPath, err := filepath.EvalSymlinks(filePath)
if err != nil {
log.Warnf("broken symlink in your abra config folders: %s", filePath)
log.Warnf(gotext.Get("broken symlink in your abra config folders: %s", filePath))
} else {
realFile, err := os.Stat(realPath)
if err != nil {
@ -94,7 +95,7 @@ func GetAllFoldersInDirectory(directory string) ([]string, error) {
return nil, err
}
if len(files) == 0 {
return nil, fmt.Errorf("directory is empty: %s", directory)
return nil, errors.New(gotext.Get("directory is empty: %s", directory))
}
for _, file := range files {
@ -103,7 +104,7 @@ func GetAllFoldersInDirectory(directory string) ([]string, error) {
filePath := path.Join(directory, file.Name())
realDir, err := filepath.EvalSymlinks(filePath)
if err != nil {
log.Warnf("broken symlink in your abra config folders: %s", filePath)
log.Warnf(gotext.Get("broken symlink in your abra config folders: %s", filePath))
} else if stat, err := os.Stat(realDir); err == nil && stat.IsDir() {
// path is a directory
folders = append(folders, file.Name())