translate: support usage translations
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

See #628
This commit is contained in:
2025-08-30 10:46:09 +02:00
parent d5c66020ad
commit 52f02ad9b9
3 changed files with 134 additions and 41 deletions

View File

@ -19,6 +19,35 @@ import (
"github.com/spf13/cobra/doc" "github.com/spf13/cobra/doc"
) )
var (
// translators: `abra` usage template. please translate only words like
// "Aliases" and "Example" and nothing inside the {{ ... }}
usageTemplate = i18n.G(`Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
)
func Run(version, commit string) { func Run(version, commit string) {
rootCmd := &cobra.Command{ rootCmd := &cobra.Command{
// translators: `abra` binary name // translators: `abra` binary name
@ -35,7 +64,6 @@ func Run(version, commit string) {
i18n.G("server"), i18n.G("server"),
i18n.G("upgrade"), i18n.G("upgrade"),
}, },
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
dirs := []map[string]os.FileMode{ dirs := []map[string]os.FileMode{
{config.ABRA_DIR: 0764}, {config.ABRA_DIR: 0764},
@ -78,6 +106,7 @@ func Run(version, commit string) {
} }
rootCmd.CompletionOptions.DisableDefaultCmd = true rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.SetUsageTemplate(usageTemplate)
manCommand := &cobra.Command{ manCommand := &cobra.Command{
// translators: `man` command // translators: `man` command

View File

@ -7,7 +7,7 @@
msgid "" msgid ""
msgstr "Project-Id-Version: \n" msgstr "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n" "Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-08-29 16:31+0200\n" "POT-Creation-Date: 2025-08-30 10:45+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -43,7 +43,7 @@ msgid " # fetch from recipe catalogue\n"
" abra recipe fetch gitea --ssh" " abra recipe fetch gitea --ssh"
msgstr "" msgstr ""
#: ./cli/run.go:88 #: ./cli/run.go:117
msgid " # generate the man pages into /usr/local/share/man/man1\n" msgid " # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n" " abra_path=$(which abra) # pass abra absolute path to sudo below\n"
" sudo $abra_path man\n" " sudo $abra_path man\n"
@ -826,7 +826,7 @@ msgid "Generate labels for the main recipe service.\n"
msgstr "" msgstr ""
#. translators: Short description for `man` command #. translators: Short description for `man` command
#: ./cli/run.go:87 #: ./cli/run.go:116
msgid "Generate manpage" msgid "Generate manpage"
msgstr "" msgstr ""
@ -1232,7 +1232,7 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr "" msgstr ""
#. translators: Short description for `abra` binary #. translators: Short description for `abra` binary
#: ./cli/run.go:27 #: ./cli/run.go:56
msgid "The Co-op Cloud command-line utility belt 🎩🐇" msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr "" msgstr ""
@ -1425,6 +1425,34 @@ msgstr ""
msgid "Upgrade recipe image tags" msgid "Upgrade recipe image tags"
msgstr "" msgstr ""
#. translators: `abra` usage template. please translate only words like
#. "Aliases" and "Example" and nothing inside the {{ ... }}
#: ./cli/run.go:25
msgid "Usage:{{if .Runnable}}\n"
" {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}\n"
" {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}\n"
"\n"
"Aliases:\n"
" {{.NameAndAliases}}{{end}}{{if .HasExample}}\n"
"\n"
"Examples:\n"
"{{.Example}}{{end}}{{if .HasAvailableSubCommands}}\n"
"\n"
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name \"help\"))}}\n"
" {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\n"
"\n"
"Flags:\n"
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\n"
"\n"
"Global Flags:\n"
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}\n"
"\n"
"Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}\n"
" {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}\n"
"\n"
"Use \"{{.CommandPath}} [command] --help\" for more information about a command.{{end}}\n"
msgstr ""
#: ./cli/recipe/release.go:320 #: ./cli/recipe/release.go:320
msgid "Use release note in release/next?" msgid "Use release note in release/next?"
msgstr "" msgstr ""
@ -1523,7 +1551,7 @@ msgid "aborting as requested"
msgstr "" msgstr ""
#. translators: `abra` binary name #. translators: `abra` binary name
#: ./cli/run.go:25 #: ./cli/run.go:54
msgid "abra [cmd] [args] [flags]" msgid "abra [cmd] [args] [flags]"
msgstr "" msgstr ""
@ -1531,7 +1559,7 @@ msgstr ""
msgid "abra app labels 1312.net" msgid "abra app labels 1312.net"
msgstr "" msgstr ""
#: ./cli/run.go:71 #: ./cli/run.go:99
#, c-format #, c-format
msgid "abra version: %s, commit: %s, lang: %s" msgid "abra version: %s, commit: %s, lang: %s"
msgstr "" msgstr ""
@ -1600,7 +1628,7 @@ msgstr ""
msgid "ambiguous service list received, prompting for input" msgid "ambiguous service list received, prompting for input"
msgstr "" msgstr ""
#: ./cli/run.go:30 #: ./cli/run.go:59
msgid "app" msgid "app"
msgstr "" msgstr ""
@ -1657,7 +1685,7 @@ msgstr ""
msgid "attempting to scale %s to 1" msgid "attempting to scale %s to 1"
msgstr "" msgstr ""
#: ./cli/run.go:31 #: ./cli/run.go:60
msgid "autocomplete" msgid "autocomplete"
msgstr "" msgstr ""
@ -1817,7 +1845,7 @@ msgstr ""
msgid "cannot use [version] and --latest together" msgid "cannot use [version] and --latest together"
msgstr "" msgstr ""
#: ./cli/run.go:32 #: ./cli/run.go:61
msgid "catalogue" msgid "catalogue"
msgstr "" msgstr ""
@ -2273,7 +2301,7 @@ msgstr ""
msgid "domain name for app" msgid "domain name for app"
msgstr "" msgstr ""
#: ./cli/run.go:112 #: ./cli/run.go:141
msgid "don't forget to run 'sudo mandb'" msgid "don't forget to run 'sudo mandb'"
msgstr "" msgstr ""
@ -3180,12 +3208,12 @@ msgstr ""
msgid "malformed version pin specification: %s" msgid "malformed version pin specification: %s"
msgstr "" msgstr ""
#: ./cli/run.go:33 #: ./cli/run.go:62
msgid "man" msgid "man"
msgstr "" msgstr ""
#. translators: `man` command #. translators: `man` command
#: ./cli/run.go:84 #: ./cli/run.go:113
msgid "man [flags]" msgid "man [flags]"
msgstr "" msgstr ""
@ -3635,7 +3663,7 @@ msgstr ""
msgid "polling undeploy status" msgid "polling undeploy status"
msgstr "" msgstr ""
#: ./cli/run.go:137 #: ./cli/run.go:166
msgid "prefer offline & filesystem access" msgid "prefer offline & filesystem access"
msgstr "" msgstr ""
@ -3760,7 +3788,7 @@ msgstr ""
msgid "readme: %s, " msgid "readme: %s, "
msgstr "" msgstr ""
#: ./cli/app/list.go:298 ./cli/app/list.go:305 ./cli/run.go:34 #: ./cli/app/list.go:298 ./cli/app/list.go:305 ./cli/run.go:63
msgid "recipe" msgid "recipe"
msgstr "" msgstr ""
@ -4157,7 +4185,7 @@ msgstr ""
msgid "secrets are %s shown again, please save them %s" msgid "secrets are %s shown again, please save them %s"
msgstr "" msgstr ""
#: ./cli/app/list.go:321 ./cli/app/list.go:328 ./cli/app/new.go:328 ./cli/app/new.go:335 ./cli/run.go:35 #: ./cli/app/list.go:321 ./cli/app/list.go:328 ./cli/app/new.go:328 ./cli/app/new.go:335 ./cli/run.go:64
msgid "server" msgid "server"
msgstr "" msgstr ""
@ -4273,7 +4301,7 @@ msgstr ""
msgid "show apps of a specific server" msgid "show apps of a specific server"
msgstr "" msgstr ""
#: ./cli/run.go:121 ./cli/updater/updater.go:499 #: ./cli/run.go:150 ./cli/updater/updater.go:499
msgid "show debug messages" msgid "show debug messages"
msgstr "" msgstr ""
@ -4547,7 +4575,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume" msgid "tmpfs options are incompatible with type volume"
msgstr "" msgstr ""
#: ./cli/run.go:129 ./cli/updater/updater.go:507 #: ./cli/run.go:158 ./cli/updater/updater.go:507
msgid "toggle non-interactive mode" msgid "toggle non-interactive mode"
msgstr "" msgstr ""
@ -4623,7 +4651,7 @@ msgstr ""
msgid "unable to convert to JSON: %s" msgid "unable to convert to JSON: %s"
msgstr "" msgstr ""
#: ./cli/run.go:51 #: ./cli/run.go:79
#, c-format #, c-format
msgid "unable to create %s: %s" msgid "unable to create %s: %s"
msgstr "" msgstr ""
@ -4712,7 +4740,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s" msgid "unable to parse '%s' value as bool: %s"
msgstr "" msgstr ""
#: ./cli/run.go:104 #: ./cli/run.go:133
#, c-format #, c-format
msgid "unable to proceed, %s does not exist?" msgid "unable to proceed, %s does not exist?"
msgstr "" msgstr ""
@ -4891,7 +4919,7 @@ msgstr ""
msgid "updating %s to %s in %s" msgid "updating %s to %s in %s"
msgstr "" msgstr ""
#: ./cli/run.go:36 #: ./cli/run.go:65
msgid "upgrade" msgid "upgrade"
msgstr "" msgstr ""

View File

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n" "Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-08-29 16:31+0200\n" "POT-Creation-Date: 2025-08-30 10:45+0200\n"
"PO-Revision-Date: 2025-08-29 08:00+0000\n" "PO-Revision-Date: 2025-08-29 08:00+0000\n"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n" "Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-" "Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-"
@ -44,7 +44,7 @@ msgid ""
" abra recipe fetch gitea --ssh" " abra recipe fetch gitea --ssh"
msgstr "" msgstr ""
#: cli/run.go:88 #: cli/run.go:117
msgid "" msgid ""
" # generate the man pages into /usr/local/share/man/man1\n" " # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n" " abra_path=$(which abra) # pass abra absolute path to sudo below\n"
@ -892,7 +892,7 @@ msgid ""
msgstr "" msgstr ""
#. translators: Short description for `man` command #. translators: Short description for `man` command
#: cli/run.go:87 #: cli/run.go:116
msgid "Generate manpage" msgid "Generate manpage"
msgstr "📒 Manual de uso" msgstr "📒 Manual de uso"
@ -1323,7 +1323,7 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr "Actualizador automático de Co-op Cloud 🤖 🚀" msgstr "Actualizador automático de Co-op Cloud 🤖 🚀"
#. translators: Short description for `abra` binary #. translators: Short description for `abra` binary
#: cli/run.go:27 #: cli/run.go:56
msgid "The Co-op Cloud command-line utility belt 🎩🐇" msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr "La varita de mágica de Co-op Cloud 🪄🎩🐇" msgstr "La varita de mágica de Co-op Cloud 🪄🎩🐇"
@ -1546,6 +1546,42 @@ msgstr "Actualizar plataformas"
msgid "Upgrade recipe image tags" msgid "Upgrade recipe image tags"
msgstr "Actualizar tags de una receta" msgstr "Actualizar tags de una receta"
#. translators: `abra` usage template. please translate only words like
#. "Aliases" and "Example" and nothing inside the {{ ... }}
#: cli/run.go:25
msgid ""
"Usage:{{if .Runnable}}\n"
" {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}\n"
" {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}\n"
"\n"
"Aliases:\n"
" {{.NameAndAliases}}{{end}}{{if .HasExample}}\n"
"\n"
"Examples:\n"
"{{.Example}}{{end}}{{if .HasAvailableSubCommands}}\n"
"\n"
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "
"\"help\"))}}\n"
" {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}"
"{{if .HasAvailableLocalFlags}}\n"
"\n"
"Flags:\n"
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}"
"{{if .HasAvailableInheritedFlags}}\n"
"\n"
"Global Flags:\n"
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}"
"{{if .HasHelpSubCommands}}\n"
"\n"
"Additional help topics:{{range .Commands}}"
"{{if .IsAdditionalHelpTopicCommand}}\n"
" {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}"
"{{if .HasAvailableSubCommands}}\n"
"\n"
"Use \"{{.CommandPath}} [command] --help\" for more information about a "
"command.{{end}}\n"
msgstr ""
#: cli/recipe/release.go:320 #: cli/recipe/release.go:320
msgid "Use release note in release/next?" msgid "Use release note in release/next?"
msgstr "" msgstr ""
@ -1666,7 +1702,7 @@ msgid "aborting as requested"
msgstr "" msgstr ""
#. translators: `abra` binary name #. translators: `abra` binary name
#: cli/run.go:25 #: cli/run.go:54
msgid "abra [cmd] [args] [flags]" msgid "abra [cmd] [args] [flags]"
msgstr "" msgstr ""
@ -1674,7 +1710,7 @@ msgstr ""
msgid "abra app labels 1312.net" msgid "abra app labels 1312.net"
msgstr "" msgstr ""
#: cli/run.go:71 #: cli/run.go:99
#, c-format #, c-format
msgid "abra version: %s, commit: %s, lang: %s" msgid "abra version: %s, commit: %s, lang: %s"
msgstr "" msgstr ""
@ -1744,7 +1780,7 @@ msgstr ""
msgid "ambiguous service list received, prompting for input" msgid "ambiguous service list received, prompting for input"
msgstr "" msgstr ""
#: cli/run.go:30 #: cli/run.go:59
msgid "app" msgid "app"
msgstr "plataforma" msgstr "plataforma"
@ -1801,7 +1837,7 @@ msgstr ""
msgid "attempting to scale %s to 1" msgid "attempting to scale %s to 1"
msgstr "" msgstr ""
#: cli/run.go:31 #: cli/run.go:60
msgid "autocomplete" msgid "autocomplete"
msgstr "" msgstr ""
@ -1968,7 +2004,7 @@ msgstr ""
msgid "cannot use [version] and --latest together" msgid "cannot use [version] and --latest together"
msgstr "" msgstr ""
#: cli/run.go:32 #: cli/run.go:61
msgid "catalogue" msgid "catalogue"
msgstr "" msgstr ""
@ -2438,7 +2474,7 @@ msgstr ""
msgid "domain name for app" msgid "domain name for app"
msgstr "" msgstr ""
#: cli/run.go:112 #: cli/run.go:141
msgid "don't forget to run 'sudo mandb'" msgid "don't forget to run 'sudo mandb'"
msgstr "" msgstr ""
@ -3373,12 +3409,12 @@ msgstr ""
msgid "malformed version pin specification: %s" msgid "malformed version pin specification: %s"
msgstr "" msgstr ""
#: cli/run.go:33 #: cli/run.go:62
msgid "man" msgid "man"
msgstr "" msgstr ""
#. translators: `man` command #. translators: `man` command
#: cli/run.go:84 #: cli/run.go:113
msgid "man [flags]" msgid "man [flags]"
msgstr "manual [flags]" msgstr "manual [flags]"
@ -3849,7 +3885,7 @@ msgstr ""
msgid "polling undeploy status" msgid "polling undeploy status"
msgstr "" msgstr ""
#: cli/run.go:137 #: cli/run.go:166
msgid "prefer offline & filesystem access" msgid "prefer offline & filesystem access"
msgstr "" msgstr ""
@ -3979,7 +4015,7 @@ msgstr ""
msgid "readme: %s, " msgid "readme: %s, "
msgstr "" msgstr ""
#: cli/app/list.go:298 cli/app/list.go:305 cli/run.go:34 #: cli/app/list.go:298 cli/app/list.go:305 cli/run.go:63
msgid "recipe" msgid "recipe"
msgstr "" msgstr ""
@ -4383,7 +4419,7 @@ msgid "secrets are %s shown again, please save them %s"
msgstr "" msgstr ""
#: cli/app/list.go:321 cli/app/list.go:328 cli/app/new.go:328 #: cli/app/list.go:321 cli/app/list.go:328 cli/app/new.go:328
#: cli/app/new.go:335 cli/run.go:35 #: cli/app/new.go:335 cli/run.go:64
msgid "server" msgid "server"
msgstr "" msgstr ""
@ -4501,7 +4537,7 @@ msgstr ""
msgid "show apps of a specific server" msgid "show apps of a specific server"
msgstr "" msgstr ""
#: cli/run.go:121 cli/updater/updater.go:499 #: cli/run.go:150 cli/updater/updater.go:499
msgid "show debug messages" msgid "show debug messages"
msgstr "" msgstr ""
@ -4778,7 +4814,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume" msgid "tmpfs options are incompatible with type volume"
msgstr "" msgstr ""
#: cli/run.go:129 cli/updater/updater.go:507 #: cli/run.go:158 cli/updater/updater.go:507
msgid "toggle non-interactive mode" msgid "toggle non-interactive mode"
msgstr "" msgstr ""
@ -4855,7 +4891,7 @@ msgstr ""
msgid "unable to convert to JSON: %s" msgid "unable to convert to JSON: %s"
msgstr "" msgstr ""
#: cli/run.go:51 #: cli/run.go:79
#, c-format #, c-format
msgid "unable to create %s: %s" msgid "unable to create %s: %s"
msgstr "" msgstr ""
@ -4945,7 +4981,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s" msgid "unable to parse '%s' value as bool: %s"
msgstr "" msgstr ""
#: cli/run.go:104 #: cli/run.go:133
#, c-format #, c-format
msgid "unable to proceed, %s does not exist?" msgid "unable to proceed, %s does not exist?"
msgstr "" msgstr ""
@ -5131,7 +5167,7 @@ msgstr ""
msgid "updating %s to %s in %s" msgid "updating %s to %s in %s"
msgstr "" msgstr ""
#: cli/run.go:36 #: cli/run.go:65
msgid "upgrade" msgid "upgrade"
msgstr "" msgstr ""