feat(i18n): translate command error and usage tip

This commit is contained in:
Goutte 2023-04-04 04:34:22 +02:00
parent ccbdd223d1
commit 6853f280ed
4 changed files with 10 additions and 2 deletions

View file

@ -1096,7 +1096,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
}
if !c.SilenceErrors {
c.PrintErrln(c.ErrPrefix(), err.Error())
c.PrintErrf("Run '%v --help' for usage.\n", c.CommandPath())
c.PrintErrf(i18nRunHelpTip()+"\n", c.CommandPath())
}
return c, err
}

View file

@ -35,6 +35,14 @@ func i18nError() string {
})
}
func i18nRunHelpTip() string {
return localizeMessage(&i18n.Message{
ID: "RunHelpTip",
Description: "tip shown when a command fails (command path)",
Other: "Run '%v --help' for usage.",
})
}
func i18nExclusiveFlagsValidationError() string {
return localizeMessage(&i18n.Message{
ID: "ExclusiveFlagsValidationError",
@ -58,7 +66,7 @@ func localizeMessage(message *i18n.Message) string {
func loadTranslationFiles(bundle *i18n.Bundle, langs []string) {
for _, lang := range langs {
_, _ = bundle.LoadMessageFileFS(localeFS, fmt.Sprintf("translations/main.%s.toml", lang))
_, _ = bundle.LoadMessageFileFS(localeFS, fmt.Sprintf("translations/active.%s.toml", lang))
}
}