fix: defer i18n.T() for package-level command vars

Package-level var declarations run at import time, before i18n is
initialised. Move Short/Long assignment to AddCommands functions
which run after Core startup.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-17 02:21:52 +00:00
parent b429736097
commit 0f50f98a95
8 changed files with 33 additions and 19 deletions

View file

@ -2,13 +2,15 @@ package deploy
import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-devops/locales"
)
func init() {
cli.RegisterCommands(AddDeployCommands)
cli.RegisterCommands(AddDeployCommands, locales.FS)
}
// AddDeployCommands registers the 'deploy' command and all subcommands.
func AddDeployCommands(root *cli.Command) {
setDeployI18n()
root.AddCommand(Cmd)
}

View file

@ -21,8 +21,11 @@ var (
// Cmd is the root deploy command.
var Cmd = &cli.Command{
Use: "deploy",
Short: i18n.T("cmd.deploy.short"),
Long: i18n.T("cmd.deploy.long"),
}
func setDeployI18n() {
Cmd.Short = i18n.T("cmd.deploy.short")
Cmd.Long = i18n.T("cmd.deploy.long")
}
var serversCmd = &cli.Command{

View file

@ -8,13 +8,17 @@
// to a central location for unified documentation builds.
package docs
import "forge.lthn.ai/core/cli/pkg/cli"
import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-devops/locales"
)
func init() {
cli.RegisterCommands(AddDocsCommands)
cli.RegisterCommands(AddDocsCommands, locales.FS)
}
// AddDocsCommands registers the 'docs' command and all subcommands.
func AddDocsCommands(root *cli.Command) {
setDocsI18n()
root.AddCommand(docsCmd)
}

View file

@ -20,8 +20,15 @@ var (
var docsCmd = &cli.Command{
Use: "docs",
Short: i18n.T("cmd.docs.short"),
Long: i18n.T("cmd.docs.long"),
}
func setDocsI18n() {
docsCmd.Short = i18n.T("cmd.docs.short")
docsCmd.Long = i18n.T("cmd.docs.long")
docsListCmd.Short = i18n.T("cmd.docs.list.short")
docsListCmd.Long = i18n.T("cmd.docs.list.long")
docsSyncCmd.Short = i18n.T("cmd.docs.sync.short")
docsSyncCmd.Long = i18n.T("cmd.docs.sync.long")
}
func init() {

View file

@ -12,8 +12,6 @@ var docsListRegistryPath string
var docsListCmd = &cli.Command{
Use: "list",
Short: i18n.T("cmd.docs.list.short"),
Long: i18n.T("cmd.docs.list.long"),
RunE: func(cmd *cli.Command, args []string) error {
return runDocsList(docsListRegistryPath)
},

View file

@ -22,8 +22,6 @@ var (
var docsSyncCmd = &cli.Command{
Use: "sync",
Short: i18n.T("cmd.docs.sync.short"),
Long: i18n.T("cmd.docs.sync.long"),
RunE: func(cmd *cli.Command, args []string) error {
return runDocsSync(docsSyncRegistryPath, docsSyncOutputDir, docsSyncDryRun, docsSyncTarget)
},

View file

@ -25,13 +25,17 @@ package setup
import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-devops/locales"
"forge.lthn.ai/core/go-i18n"
)
func init() {
cli.RegisterCommands(AddSetupCommands)
cli.RegisterCommands(AddSetupCommands, locales.FS)
}
// AddSetupCommands registers the 'setup' command and all subcommands.
func AddSetupCommands(root *cli.Command) {
setupCmd.Short = i18n.T("cmd.setup.short")
setupCmd.Long = i18n.T("cmd.setup.long")
AddSetupCommand(root)
}

View file

@ -34,8 +34,6 @@ var (
var setupCmd = &cli.Command{
Use: "setup",
Short: i18n.T("cmd.setup.short"),
Long: i18n.T("cmd.setup.long"),
RunE: func(cmd *cli.Command, args []string) error {
return runSetupOrchestrator(registryPath, only, dryRun, all, name, build)
},