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 396f0f4406
107 changed files with 15977 additions and 1645 deletions

View File

@ -8,6 +8,7 @@ import (
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/ui"
upstream "coopcloud.tech/abra/pkg/upstream/service"
@ -17,19 +18,19 @@ import (
)
var AppRestartCommand = &cobra.Command{
Use: "restart <domain> [[service] | --all-services] [flags]",
Aliases: []string{"re"},
Short: "Restart an app",
Long: `This command restarts services within a deployed app.
Use: i18n.G("restart <domain> [[service] | --all-services] [flags]"),
Aliases: []string{i18n.G("re")},
Short: i18n.G("Restart an app"),
Long: i18n.G(`This command restarts services within a deployed app.
Run "abra app ps <domain>" to see a list of service names.
Pass "--all-services/-a" to restart all services.`,
Example: ` # restart a single app service
Pass "--all-services/-a" to restart all services.`),
Example: i18n.G(` # restart a single app service
abra app restart 1312.net app
# restart all app services
abra app restart 1312.net -a`,
abra app restart 1312.net -a`),
Args: cobra.RangeArgs(1, 2),
ValidArgsFunction: func(
cmd *cobra.Command,
@ -60,11 +61,11 @@ Pass "--all-services/-a" to restart all services.`,
}
if serviceName == "" && !allServices {
log.Fatal("missing [service]")
log.Fatal(i18n.G("missing [service]"))
}
if serviceName != "" && allServices {
log.Fatal("cannot use [service] and --all-services/-a together")
log.Fatal(i18n.G("cannot use [service] and --all-services/-a together"))
}
var serviceNames []string
@ -89,7 +90,7 @@ Pass "--all-services/-a" to restart all services.`,
}
if !deployMeta.IsDeployed {
log.Fatalf("%s is not deployed?", app.Name)
log.Fatal(i18n.G("%s is not deployed?", app.Name))
}
for _, serviceName := range serviceNames {
@ -104,7 +105,7 @@ Pass "--all-services/-a" to restart all services.`,
log.Fatal(err)
}
log.Debugf("attempting to scale %s to 0", stackServiceName)
log.Debug(i18n.G("attempting to scale %s to 0", stackServiceName))
if err := upstream.RunServiceScale(context.Background(), cl, stackServiceName, 0); err != nil {
log.Fatal(err)
@ -128,8 +129,8 @@ Pass "--all-services/-a" to restart all services.`,
log.Fatal(err)
}
log.Debugf("%s has been scaled to 0", stackServiceName)
log.Debugf("attempting to scale %s to 1", stackServiceName)
log.Debug(i18n.G("%s has been scaled to 0", stackServiceName))
log.Debug(i18n.G("attempting to scale %s to 1", stackServiceName))
if err := upstream.RunServiceScale(context.Background(), cl, stackServiceName, 1); err != nil {
log.Fatal(err)
@ -139,8 +140,8 @@ Pass "--all-services/-a" to restart all services.`,
log.Fatal(err)
}
log.Debugf("%s has been scaled to 1", stackServiceName)
log.Infof("%s service successfully restarted", serviceName)
log.Debug(i18n.G("%s has been scaled to 1", stackServiceName))
log.Info(i18n.G("%s service successfully restarted", serviceName))
}
},
}
@ -150,16 +151,16 @@ var allServices bool
func init() {
AppRestartCommand.Flags().BoolVarP(
&internal.Chaos,
"chaos",
"C",
i18n.G("chaos"),
i18n.G("C"),
false,
"ignore uncommitted recipes changes",
i18n.G("ignore uncommitted recipes changes"),
)
AppRestartCommand.Flags().BoolVarP(
&allServices,
"all-services",
"a",
i18n.G("all-services"),
i18n.G("a"),
false,
"restart all services",
i18n.G("restart all services"),
)
}