feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing

See #483
This commit is contained in:
2025-08-19 11:22:52 +02:00
parent 5cf6048ecb
commit ff32c06676
49 changed files with 466 additions and 405 deletions

View File

@ -12,23 +12,24 @@ import (
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/log"
charmLog "github.com/charmbracelet/log"
"github.com/leonelquinteros/gotext"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
func Run(version, commit string) {
rootCmd := &cobra.Command{
Use: "abra [cmd] [args] [flags]",
Short: "The Co-op Cloud command-line utility belt 🎩🐇",
Use: gotext.Get("abra [cmd] [args] [flags]"),
Short: gotext.Get("The Co-op Cloud command-line utility belt 🎩🐇"),
Version: fmt.Sprintf("%s-%s", version, commit[:7]),
ValidArgs: []string{
"app",
"autocomplete",
"catalogue",
"man",
"recipe",
"server",
"upgrade",
gotext.Get("app"),
gotext.Get("autocomplete"),
gotext.Get("catalogue"),
gotext.Get("man"),
gotext.Get("recipe"),
gotext.Get("server"),
gotext.Get("upgrade"),
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
dirs := []map[string]os.FileMode{
@ -62,24 +63,24 @@ func Run(version, commit string) {
log.SetReportCaller(true)
}
log.Debugf("abra version %s, commit %s", version, commit)
log.Debugf(gotext.Get("abra version %s, commit %s", version, commit))
},
}
rootCmd.CompletionOptions.DisableDefaultCmd = true
manCommand := &cobra.Command{
Use: "man [flags]",
Use: gotext.Get("man [flags]"),
Aliases: []string{"m"},
Short: "Generate manpage",
Example: ` # generate the man pages into /usr/local/share/man/man1
Short: gotext.Get("Generate manpage"),
Example: gotext.Get(` # generate the man pages into /usr/local/share/man/man1
abra_path=$(which abra) # pass abra absolute path to sudo below
sudo $abra_path man
sudo mandb
# read the man pages
man abra
man abra-app-deploy`,
man abra-app-deploy`),
Run: func(cmd *cobra.Command, args []string) {
header := &doc.GenManHeader{
Title: "ABRA",
@ -88,7 +89,7 @@ func Run(version, commit string) {
manDir := "/usr/local/share/man/man1"
if _, err := os.Stat(manDir); os.IsNotExist(err) {
log.Fatalf("unable to proceed, '%s' does not exist?")
log.Fatal(gotext.Get("unable to proceed, %s does not exist?", manDir))
}
err := doc.GenManTree(rootCmd, header, manDir)
@ -96,7 +97,7 @@ func Run(version, commit string) {
log.Fatal(err)
}
log.Info("don't forget to run 'sudo mandb'")
log.Info(gotext.Get("don't forget to run 'sudo mandb'"))
},
}
@ -105,7 +106,7 @@ func Run(version, commit string) {
"debug",
"d",
false,
"show debug messages",
gotext.Get("show debug messages"),
)
rootCmd.PersistentFlags().BoolVarP(
@ -113,7 +114,7 @@ func Run(version, commit string) {
"no-input",
"n",
false,
"toggle non-interactive mode",
gotext.Get("toggle non-interactive mode"),
)
rootCmd.PersistentFlags().BoolVarP(
@ -121,7 +122,7 @@ func Run(version, commit string) {
"offline",
"o",
false,
"prefer offline & filesystem access",
gotext.Get("prefer offline & filesystem access"),
)
rootCmd.PersistentFlags().BoolVarP(
@ -129,7 +130,7 @@ func Run(version, commit string) {
"ignore-env-version",
"i",
false,
"ignore .env version checkout",
gotext.Get("ignore .env version checkout"),
)
catalogue.CatalogueCommand.AddCommand(