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"
)
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) {
rootCmd := &cobra.Command{
// translators: `abra` binary name
@ -35,7 +64,6 @@ func Run(version, commit string) {
i18n.G("server"),
i18n.G("upgrade"),
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
dirs := []map[string]os.FileMode{
{config.ABRA_DIR: 0764},
@ -78,6 +106,7 @@ func Run(version, commit string) {
}
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.SetUsageTemplate(usageTemplate)
manCommand := &cobra.Command{
// translators: `man` command

View File

@ -7,7 +7,7 @@
msgid ""
msgstr "Project-Id-Version: \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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -43,7 +43,7 @@ msgid " # fetch from recipe catalogue\n"
" abra recipe fetch gitea --ssh"
msgstr ""
#: ./cli/run.go:88
#: ./cli/run.go:117
msgid " # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n"
" sudo $abra_path man\n"
@ -826,7 +826,7 @@ msgid "Generate labels for the main recipe service.\n"
msgstr ""
#. translators: Short description for `man` command
#: ./cli/run.go:87
#: ./cli/run.go:116
msgid "Generate manpage"
msgstr ""
@ -1232,7 +1232,7 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr ""
#. translators: Short description for `abra` binary
#: ./cli/run.go:27
#: ./cli/run.go:56
msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr ""
@ -1425,6 +1425,34 @@ msgstr ""
msgid "Upgrade recipe image tags"
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
msgid "Use release note in release/next?"
msgstr ""
@ -1523,7 +1551,7 @@ msgid "aborting as requested"
msgstr ""
#. translators: `abra` binary name
#: ./cli/run.go:25
#: ./cli/run.go:54
msgid "abra [cmd] [args] [flags]"
msgstr ""
@ -1531,7 +1559,7 @@ msgstr ""
msgid "abra app labels 1312.net"
msgstr ""
#: ./cli/run.go:71
#: ./cli/run.go:99
#, c-format
msgid "abra version: %s, commit: %s, lang: %s"
msgstr ""
@ -1600,7 +1628,7 @@ msgstr ""
msgid "ambiguous service list received, prompting for input"
msgstr ""
#: ./cli/run.go:30
#: ./cli/run.go:59
msgid "app"
msgstr ""
@ -1657,7 +1685,7 @@ msgstr ""
msgid "attempting to scale %s to 1"
msgstr ""
#: ./cli/run.go:31
#: ./cli/run.go:60
msgid "autocomplete"
msgstr ""
@ -1817,7 +1845,7 @@ msgstr ""
msgid "cannot use [version] and --latest together"
msgstr ""
#: ./cli/run.go:32
#: ./cli/run.go:61
msgid "catalogue"
msgstr ""
@ -2273,7 +2301,7 @@ msgstr ""
msgid "domain name for app"
msgstr ""
#: ./cli/run.go:112
#: ./cli/run.go:141
msgid "don't forget to run 'sudo mandb'"
msgstr ""
@ -3180,12 +3208,12 @@ msgstr ""
msgid "malformed version pin specification: %s"
msgstr ""
#: ./cli/run.go:33
#: ./cli/run.go:62
msgid "man"
msgstr ""
#. translators: `man` command
#: ./cli/run.go:84
#: ./cli/run.go:113
msgid "man [flags]"
msgstr ""
@ -3635,7 +3663,7 @@ msgstr ""
msgid "polling undeploy status"
msgstr ""
#: ./cli/run.go:137
#: ./cli/run.go:166
msgid "prefer offline & filesystem access"
msgstr ""
@ -3760,7 +3788,7 @@ msgstr ""
msgid "readme: %s, "
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"
msgstr ""
@ -4157,7 +4185,7 @@ msgstr ""
msgid "secrets are %s shown again, please save them %s"
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"
msgstr ""
@ -4273,7 +4301,7 @@ msgstr ""
msgid "show apps of a specific server"
msgstr ""
#: ./cli/run.go:121 ./cli/updater/updater.go:499
#: ./cli/run.go:150 ./cli/updater/updater.go:499
msgid "show debug messages"
msgstr ""
@ -4547,7 +4575,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume"
msgstr ""
#: ./cli/run.go:129 ./cli/updater/updater.go:507
#: ./cli/run.go:158 ./cli/updater/updater.go:507
msgid "toggle non-interactive mode"
msgstr ""
@ -4623,7 +4651,7 @@ msgstr ""
msgid "unable to convert to JSON: %s"
msgstr ""
#: ./cli/run.go:51
#: ./cli/run.go:79
#, c-format
msgid "unable to create %s: %s"
msgstr ""
@ -4712,7 +4740,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s"
msgstr ""
#: ./cli/run.go:104
#: ./cli/run.go:133
#, c-format
msgid "unable to proceed, %s does not exist?"
msgstr ""
@ -4891,7 +4919,7 @@ msgstr ""
msgid "updating %s to %s in %s"
msgstr ""
#: ./cli/run.go:36
#: ./cli/run.go:65
msgid "upgrade"
msgstr ""

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \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"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-"
@ -44,7 +44,7 @@ msgid ""
" abra recipe fetch gitea --ssh"
msgstr ""
#: cli/run.go:88
#: cli/run.go:117
msgid ""
" # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n"
@ -892,7 +892,7 @@ msgid ""
msgstr ""
#. translators: Short description for `man` command
#: cli/run.go:87
#: cli/run.go:116
msgid "Generate manpage"
msgstr "📒 Manual de uso"
@ -1323,7 +1323,7 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr "Actualizador automático de Co-op Cloud 🤖 🚀"
#. translators: Short description for `abra` binary
#: cli/run.go:27
#: cli/run.go:56
msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr "La varita de mágica de Co-op Cloud 🪄🎩🐇"
@ -1546,6 +1546,42 @@ msgstr "Actualizar plataformas"
msgid "Upgrade recipe image tags"
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
msgid "Use release note in release/next?"
msgstr ""
@ -1666,7 +1702,7 @@ msgid "aborting as requested"
msgstr ""
#. translators: `abra` binary name
#: cli/run.go:25
#: cli/run.go:54
msgid "abra [cmd] [args] [flags]"
msgstr ""
@ -1674,7 +1710,7 @@ msgstr ""
msgid "abra app labels 1312.net"
msgstr ""
#: cli/run.go:71
#: cli/run.go:99
#, c-format
msgid "abra version: %s, commit: %s, lang: %s"
msgstr ""
@ -1744,7 +1780,7 @@ msgstr ""
msgid "ambiguous service list received, prompting for input"
msgstr ""
#: cli/run.go:30
#: cli/run.go:59
msgid "app"
msgstr "plataforma"
@ -1801,7 +1837,7 @@ msgstr ""
msgid "attempting to scale %s to 1"
msgstr ""
#: cli/run.go:31
#: cli/run.go:60
msgid "autocomplete"
msgstr ""
@ -1968,7 +2004,7 @@ msgstr ""
msgid "cannot use [version] and --latest together"
msgstr ""
#: cli/run.go:32
#: cli/run.go:61
msgid "catalogue"
msgstr ""
@ -2438,7 +2474,7 @@ msgstr ""
msgid "domain name for app"
msgstr ""
#: cli/run.go:112
#: cli/run.go:141
msgid "don't forget to run 'sudo mandb'"
msgstr ""
@ -3373,12 +3409,12 @@ msgstr ""
msgid "malformed version pin specification: %s"
msgstr ""
#: cli/run.go:33
#: cli/run.go:62
msgid "man"
msgstr ""
#. translators: `man` command
#: cli/run.go:84
#: cli/run.go:113
msgid "man [flags]"
msgstr "manual [flags]"
@ -3849,7 +3885,7 @@ msgstr ""
msgid "polling undeploy status"
msgstr ""
#: cli/run.go:137
#: cli/run.go:166
msgid "prefer offline & filesystem access"
msgstr ""
@ -3979,7 +4015,7 @@ msgstr ""
msgid "readme: %s, "
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"
msgstr ""
@ -4383,7 +4419,7 @@ msgid "secrets are %s shown again, please save them %s"
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/new.go:335 cli/run.go:64
msgid "server"
msgstr ""
@ -4501,7 +4537,7 @@ msgstr ""
msgid "show apps of a specific server"
msgstr ""
#: cli/run.go:121 cli/updater/updater.go:499
#: cli/run.go:150 cli/updater/updater.go:499
msgid "show debug messages"
msgstr ""
@ -4778,7 +4814,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume"
msgstr ""
#: cli/run.go:129 cli/updater/updater.go:507
#: cli/run.go:158 cli/updater/updater.go:507
msgid "toggle non-interactive mode"
msgstr ""
@ -4855,7 +4891,7 @@ msgstr ""
msgid "unable to convert to JSON: %s"
msgstr ""
#: cli/run.go:51
#: cli/run.go:79
#, c-format
msgid "unable to create %s: %s"
msgstr ""
@ -4945,7 +4981,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s"
msgstr ""
#: cli/run.go:104
#: cli/run.go:133
#, c-format
msgid "unable to proceed, %s does not exist?"
msgstr ""
@ -5131,7 +5167,7 @@ msgstr ""
msgid "updating %s to %s in %s"
msgstr ""
#: cli/run.go:36
#: cli/run.go:65
msgid "upgrade"
msgstr ""