feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #483
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@ -39,7 +40,7 @@ func RunExec(dockerCli command.Cli, client *apiclient.Client, containerID string
|
||||
|
||||
execID := response.ID
|
||||
if execID == "" {
|
||||
return nil, errors.New("exec ID empty")
|
||||
return nil, errors.New(i18n.G("exec ID empty"))
|
||||
}
|
||||
|
||||
if execOptions.Detach {
|
||||
@ -104,12 +105,12 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, client *apiclie
|
||||
|
||||
if execOpts.Tty && dockerCli.In().IsTerminal() {
|
||||
if err := MonitorTtySize(ctx, client, dockerCli, execID, true); err != nil {
|
||||
fmt.Fprintln(dockerCli.Err(), "Error monitoring TTY size:", err)
|
||||
fmt.Fprintln(dockerCli.Err(), i18n.G("Error monitoring TTY size:"), err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := <-errCh; err != nil {
|
||||
log.Debugf("Error hijack: %s", err)
|
||||
log.Debug(i18n.G("Error hijack: %s", err))
|
||||
return out, err
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,12 @@ package container // https://github.com/docker/cli/blob/master/cli/command/conta
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -39,7 +40,7 @@ type hijackedIOStreamer struct {
|
||||
func (h *hijackedIOStreamer) stream(ctx context.Context) error {
|
||||
restoreInput, err := h.setupInput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to setup input stream: %s", err)
|
||||
return errors.New(i18n.G("unable to setup input stream: %s", err))
|
||||
}
|
||||
|
||||
defer restoreInput()
|
||||
@ -78,7 +79,7 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
|
||||
}
|
||||
|
||||
if err := setRawTerminal(h.streams); err != nil {
|
||||
return nil, fmt.Errorf("unable to set IO streams as raw terminal: %s", err)
|
||||
return nil, errors.New(i18n.G("unable to set IO streams as raw terminal: %s", err))
|
||||
}
|
||||
|
||||
// Use sync.Once so we may call restore multiple times but ensure we
|
||||
@ -96,7 +97,7 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
|
||||
if h.detachKeys != "" {
|
||||
customEscapeKeys, err := term.ToBytes(h.detachKeys)
|
||||
if err != nil {
|
||||
log.Warnf("invalid detach escape keys, using default: %s", err)
|
||||
log.Warnf(i18n.G("invalid detach escape keys, using default: %s", err))
|
||||
} else {
|
||||
escapeKeys = customEscapeKeys
|
||||
}
|
||||
@ -128,10 +129,10 @@ func (h *hijackedIOStreamer) beginOutputStream(restoreInput func()) <-chan error
|
||||
_, err = stdcopy.StdCopy(h.outputStream, h.errorStream, h.resp.Reader)
|
||||
}
|
||||
|
||||
log.Debug("[hijack] End of stdout")
|
||||
log.Debug(i18n.G("[hijack] end of stdout"))
|
||||
|
||||
if err != nil {
|
||||
log.Debugf("Error receiveStdout: %s", err)
|
||||
log.Debug(i18n.G("error receiveStdout: %s", err))
|
||||
}
|
||||
|
||||
outputDone <- err
|
||||
@ -152,7 +153,7 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
|
||||
// messages will be in normal type.
|
||||
restoreInput()
|
||||
|
||||
log.Debug("[hijack] End of stdin")
|
||||
log.Debug(i18n.G("[hijack] End of stdin"))
|
||||
|
||||
if _, ok := err.(term.EscapeError); ok {
|
||||
detached <- err
|
||||
@ -163,12 +164,12 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
|
||||
// This error will also occur on the receive
|
||||
// side (from stdout) where it will be
|
||||
// propagated back to the caller.
|
||||
log.Debugf("Error sendStdin: %s", err)
|
||||
log.Debug(i18n.G("error sendStdin: %s", err))
|
||||
}
|
||||
}
|
||||
|
||||
if err := h.resp.CloseWrite(); err != nil {
|
||||
log.Debugf("Couldn't send EOF: %s", err)
|
||||
log.Debug(i18n.G("couldn't send EOF: %s", err))
|
||||
}
|
||||
|
||||
close(inputDone)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
@ -35,7 +36,7 @@ func resizeTtyTo(ctx context.Context, client client.ContainerAPIClient, id strin
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Debugf("Error resize: %s\r", err)
|
||||
log.Debug(fmt.Sprintf("%s\r", i18n.G("error resize: %s", err)))
|
||||
}
|
||||
return err
|
||||
}
|
||||
@ -62,7 +63,7 @@ func initTtySize(ctx context.Context, client *apiclient.Client, cli command.Cli,
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintln(cli.Err(), "failed to resize tty, using default size")
|
||||
fmt.Fprintln(cli.Err(), i18n.G("failed to resize tty, using default size"))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Reference in New Issue
Block a user