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:
@ -8,15 +8,16 @@ import (
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
contextPkg "coopcloud.tech/abra/pkg/context"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/docker/cli/cli/connhelper/ssh"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var ServerListCommand = &cobra.Command{
|
||||
Use: "list [flags]",
|
||||
Aliases: []string{"ls"},
|
||||
Short: "List managed servers",
|
||||
Use: i18n.G("list [flags]"),
|
||||
Aliases: []string{i18n.G("ls")},
|
||||
Short: i18n.G("List managed servers"),
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
dockerContextStore := contextPkg.NewDefaultDockerContextStore()
|
||||
@ -30,7 +31,7 @@ var ServerListCommand = &cobra.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
headers := []string{"NAME", "HOST"}
|
||||
headers := []string{i18n.G("NAME"), i18n.G("HOST")}
|
||||
table.Headers(headers...)
|
||||
|
||||
serverNames, err := config.ReadServerNames()
|
||||
@ -55,7 +56,7 @@ var ServerListCommand = &cobra.Command{
|
||||
}
|
||||
|
||||
if sp.Host == "" {
|
||||
sp.Host = "unknown"
|
||||
sp.Host = i18n.G("unknown")
|
||||
}
|
||||
|
||||
row = []string{serverName, sp.Host}
|
||||
@ -65,9 +66,9 @@ var ServerListCommand = &cobra.Command{
|
||||
|
||||
if len(row) == 0 {
|
||||
if serverName == "default" {
|
||||
row = []string{serverName, "local"}
|
||||
row = []string{serverName, i18n.G("local")}
|
||||
} else {
|
||||
row = []string{serverName, "unknown"}
|
||||
row = []string{serverName, i18n.G("unknown")}
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
@ -78,7 +79,7 @@ var ServerListCommand = &cobra.Command{
|
||||
if internal.MachineReadable {
|
||||
out, err := formatter.ToJSON(headers, rows)
|
||||
if err != nil {
|
||||
log.Fatal("unable to render to JSON: %s", err)
|
||||
log.Fatal(i18n.G("unable to render to JSON: %s", err))
|
||||
}
|
||||
|
||||
fmt.Println(out)
|
||||
@ -95,9 +96,9 @@ var ServerListCommand = &cobra.Command{
|
||||
func init() {
|
||||
ServerListCommand.Flags().BoolVarP(
|
||||
&internal.MachineReadable,
|
||||
"machine",
|
||||
"m",
|
||||
i18n.G("machine"),
|
||||
i18n.G("m"),
|
||||
false,
|
||||
"print machine-readable output",
|
||||
i18n.G("print machine-readable output"),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user