-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Related to #1134 but a separate topic. Related: #719 (and maybe #2185)
I'm working on a project where there is a need to translate sub-commands and flags.
So, for example:
var FooCommand = &cobra.Command{
Use: gotext.Get("foo [flags]"),
Aliases: []string{"f"},
Short: gotext.Get("Short text"),
Long: gotext.Get("Long text")
// ...
}
func init() {
FooCommand.Flags().BoolVarP(
&publish,
gotext.Get("publish"),
gotext.Get("p")
false,
gotext.Get("publish changes"),
)
}So if you had a default en.po:
#: foo.go:4
msgid "foo [flags]"
msgstr ""And a es.po translation:
#: foo.go:4
msgid "foo [flags]"
msgstr "bar [flags]"So that users can LANG=en mycli foo / LANG=es mycli bar and run the same sub-command. I assume this would be best considered a sort of command translation alias? Also it should be visible in the help output and flags should be translated. This doesn't work atm.
I understand I can override the help template but I am more unsure about the sub-command name. I'm actually not even sure this is supported or if the command generation is based on the strings? Maybe @Goutte you have some ideas actually re: your work on #2090 and previous experiences.