Mark user interface strings

For now exclude command help, as cobra itself is not localizable yet.
This commit is contained in:
Philipp Wolfer 2023-12-09 16:43:14 +01:00
parent 511b71b909
commit d6ca8d33f7
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
27 changed files with 1005 additions and 95 deletions

View file

@ -29,12 +29,13 @@ import (
"github.com/spf13/cobra"
"go.uploadedlobster.com/scotty/internal/cli"
"go.uploadedlobster.com/scotty/internal/config"
"go.uploadedlobster.com/scotty/internal/i18n"
)
var serviceAddCmd = &cobra.Command{
Use: "add",
Short: "Add a service configuration",
Long: `Add a service configuration.`,
Long: `Interactively add a service to the configuration file.`,
Run: func(cmd *cobra.Command, args []string) {
// Select backend
backend, err := cli.SelectBackend("")
@ -42,12 +43,12 @@ var serviceAddCmd = &cobra.Command{
// Set service name
prompt := promptui.Prompt{
Label: "Service name",
Label: i18n.Tr("Service name"),
Default: backend,
Validate: func(s string) error {
srv, _ := config.GetService(s)
if srv != nil {
return errors.New("a service with this name already exists")
return errors.New(i18n.Tr("a service with this name already exists"))
}
return config.ValidateKey(s)
},
@ -69,7 +70,7 @@ var serviceAddCmd = &cobra.Command{
// Save the service config
err = service.Save()
cobra.CheckErr(err)
fmt.Printf("Saved service %v using backend %v\n", service.Name, service.Backend)
fmt.Println(i18n.Tr("Saved service %v using backend %v", service.Name, service.Backend))
},
}