feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing

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

View File

@ -4,12 +4,12 @@ package client
import (
"context"
"errors"
"fmt"
"net/http"
"os"
"time"
contextPkg "coopcloud.tech/abra/pkg/context"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
sshPkg "coopcloud.tech/abra/pkg/ssh"
commandconnPkg "coopcloud.tech/abra/pkg/upstream/commandconn"
@ -41,7 +41,7 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
if serverName != "default" {
context, err := GetContext(serverName)
if err != nil {
return nil, fmt.Errorf("unknown server, run \"abra server add %s\"?", serverName)
return nil, errors.New(i18n.G("unknown server, run \"abra server add %s\"?", serverName))
}
ctxEndpoint, err := contextPkg.GetContextEndpoint(context)
@ -85,7 +85,7 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
return nil, err
}
log.Debugf("created client for %s", serverName)
log.Debug(i18n.G("created client for %s", serverName))
info, err := cl.Info(context.Background())
if err != nil {
@ -94,10 +94,10 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
if info.Swarm.LocalNodeState == "inactive" {
if serverName != "default" {
return cl, fmt.Errorf("swarm mode not enabled on %s?", serverName)
return cl, errors.New(i18n.G("swarm mode not enabled on %s?", serverName))
}
return cl, errors.New("swarm mode not enabled on local server?")
return cl, errors.New(i18n.G("swarm mode not enabled on local server?"))
}
return cl, nil

View File

@ -2,8 +2,9 @@ package client
import (
"context"
"fmt"
"errors"
"coopcloud.tech/abra/pkg/i18n"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
@ -31,7 +32,7 @@ func GetConfigNames(configs []swarm.Config) []string {
func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string, force bool) error {
for _, confName := range configNames {
if err := cl.ConfigRemove(context.Background(), confName); err != nil {
return fmt.Errorf("conf %s: %s", confName, err)
return errors.New(i18n.G("conf %s: %s", confName, err))
}
}
return nil

View File

@ -5,6 +5,7 @@ import (
"fmt"
"coopcloud.tech/abra/pkg/context"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
commandconnPkg "coopcloud.tech/abra/pkg/upstream/commandconn"
dConfig "github.com/docker/cli/cli/config"
@ -22,7 +23,7 @@ func CreateContext(contextName string) error {
return err
}
log.Debugf("created the %s context", contextName)
log.Debug(i18n.G("created the %s context", contextName))
return nil
}
@ -62,7 +63,7 @@ func createContext(name string, host string) error {
func DeleteContext(name string) error {
if name == "default" {
return errors.New("context 'default' cannot be removed")
return errors.New(i18n.G("context 'default' cannot be removed"))
}
if _, err := GetContext(name); err != nil {

View File

@ -2,8 +2,10 @@ package client
import (
"context"
"errors"
"fmt"
"coopcloud.tech/abra/pkg/i18n"
"github.com/containers/image/docker"
"github.com/containers/image/types"
"github.com/distribution/reference"
@ -15,7 +17,7 @@ func GetRegistryTags(img reference.Named) ([]string, error) {
ref, err := docker.ParseReference(fmt.Sprintf("//%s", img))
if err != nil {
return tags, fmt.Errorf("failed to parse image %s, saw: %s", img, err.Error())
return tags, errors.New(i18n.G("failed to parse image %s, saw: %s", img, err.Error()))
}
ctx := context.Background()

View File

@ -2,9 +2,10 @@ package client
import (
"context"
"fmt"
"errors"
"time"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
@ -37,7 +38,7 @@ func RemoveVolumes(cl *client.Client, ctx context.Context, volumeNames []string,
return cl.VolumeRemove(context.Background(), volName, force)
})
if err != nil {
return fmt.Errorf("volume %s: %s", volName, err)
return errors.New(i18n.G("volume %s: %s", volName, err))
}
}
return nil
@ -54,9 +55,9 @@ func retryFunc(retries int, fn func() error) error {
}
if i+1 < retries {
sleep := time.Duration(i+1) * time.Duration(i+1)
log.Infof("%s: waiting %d seconds before next retry", err, sleep)
log.Info(i18n.G("%s: waiting %d seconds before next retry", err, sleep))
time.Sleep(sleep * time.Second)
}
}
return fmt.Errorf("%d retries failed", retries)
return errors.New(i18n.G("%d retries failed", retries))
}