mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 13:57:56 +02:00
Mark user interface strings
For now exclude command help, as cobra itself is not localizable yet.
This commit is contained in:
parent
511b71b909
commit
d6ca8d33f7
27 changed files with 1005 additions and 95 deletions
|
@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue