From 96eaed507c358d3ff3f126eee9066d9e2667a791 Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 30 Jan 2026 23:09:45 +0000 Subject: [PATCH] refactor(i18n): migrate all pkg/* to grammar engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace verbose map-based translation calls with concise grammar engine helpers across all command packages: - i18n.T("common.label.xxx") → i18n.Label("xxx") - i18n.T("common.error.failed", map) → i18n.T("i18n.fail.verb", subj) - i18n.T("common.progress.running", map) → i18n.ProgressSubject() - i18n.T("common.count.xxx", map) → i18n.T("i18n.count.xxx", n) Packages updated: ai, ci, dev, docs, php, pkgcmd, sdk, setup, test, vm Co-Authored-By: Claude Opus 4.5 --- pkg/ai/cmd_git.go | 46 ++++++++++++------------- pkg/ai/cmd_tasks.go | 22 ++++++------ pkg/ai/cmd_updates.go | 12 +++---- pkg/ci/cmd_changelog.go | 6 ++-- pkg/ci/cmd_init.go | 8 ++--- pkg/ci/cmd_publish.go | 10 +++--- pkg/ci/cmd_version.go | 6 ++-- pkg/dev/cmd_ci.go | 2 +- pkg/dev/cmd_commit.go | 4 +-- pkg/dev/cmd_impact.go | 2 +- pkg/dev/cmd_issues.go | 2 +- pkg/dev/cmd_pull.go | 4 +-- pkg/dev/cmd_push.go | 4 +-- pkg/dev/cmd_reviews.go | 2 +- pkg/dev/cmd_sync.go | 4 +-- pkg/dev/cmd_vm.go | 10 +++--- pkg/dev/cmd_work.go | 6 ++-- pkg/docs/cmd_list.go | 4 +-- pkg/docs/cmd_scan.go | 6 ++-- pkg/docs/cmd_sync.go | 4 +-- pkg/php/cmd_build.go | 24 +++++++------- pkg/php/cmd_deploy.go | 32 +++++++++--------- pkg/php/cmd_dev.go | 24 +++++++------- pkg/php/cmd_packages.go | 24 +++++++------- pkg/php/cmd_quality.go | 70 +++++++++++++++++++-------------------- pkg/pkgcmd/cmd_install.go | 8 ++--- pkg/pkgcmd/cmd_manage.go | 14 ++++---- pkg/pkgcmd/cmd_search.go | 4 +-- pkg/sdk/cmd_sdk.go | 14 ++++---- pkg/setup/cmd_registry.go | 14 ++++---- pkg/test/cmd_output.go | 8 ++--- pkg/test/cmd_runner.go | 10 +++--- pkg/vm/cmd_container.go | 22 ++++++------ 33 files changed, 216 insertions(+), 216 deletions(-) diff --git a/pkg/ai/cmd_git.go b/pkg/ai/cmd_git.go index 237fe2e..8451b4c 100644 --- a/pkg/ai/cmd_git.go +++ b/pkg/ai/cmd_git.go @@ -40,12 +40,12 @@ var taskCommitCmd = &cobra.Command{ taskID := args[0] if taskCommitMessage == "" { - return fmt.Errorf("%s", i18n.T("cmd.ai.task_commit.message_required")) + return fmt.Errorf("commit message required") } cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -56,7 +56,7 @@ var taskCommitCmd = &cobra.Command{ // Get task details task, err := client.GetTask(ctx, taskID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "task"), err) } // Build commit message with optional scope @@ -71,35 +71,35 @@ var taskCommitCmd = &cobra.Command{ // Get current directory cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Check for uncommitted changes hasChanges, err := agentic.HasUncommittedChanges(ctx, cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "check git status"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.check", "git status"), err) } if !hasChanges { - fmt.Println(i18n.T("cmd.ai.task_commit.no_changes")) + fmt.Println("No changes to commit") return nil } // Create commit - fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_commit.creating", map[string]interface{}{"ID": taskID})) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.ProgressSubject("create", "commit for "+taskID)) if err := agentic.AutoCommit(ctx, task, cwd, fullMessage); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "commit"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.commit"), err) } - fmt.Printf("%s %s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_commit.committed"), fullMessage) + fmt.Printf("%s %s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.commit")+":", fullMessage) // Push if requested if taskCommitPush { - fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_commit.pushing")) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.Progress("push")) if err := agentic.PushChanges(ctx, cwd); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "push"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.push"), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Changes pushed"})) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.push", "changes")) } return nil @@ -116,7 +116,7 @@ var taskPRCmd = &cobra.Command{ cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -127,31 +127,31 @@ var taskPRCmd = &cobra.Command{ // Get task details task, err := client.GetTask(ctx, taskID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "task"), err) } // Get current directory cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Check current branch branch, err := agentic.GetCurrentBranch(ctx, cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get current branch"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "branch"), err) } if branch == "main" || branch == "master" { - return fmt.Errorf("%s", i18n.T("cmd.ai.task_pr.branch_error", map[string]interface{}{"Branch": branch})) + return fmt.Errorf("cannot create PR from %s branch", branch) } // Push current branch - fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_pr.pushing_branch", map[string]interface{}{"Branch": branch})) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.ProgressSubject("push", branch)) if err := agentic.PushChanges(ctx, cwd); err != nil { // Try setting upstream if _, err := runGitCommand(cwd, "push", "-u", "origin", branch); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "push branch"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.push", "branch"), err) } } @@ -167,14 +167,14 @@ var taskPRCmd = &cobra.Command{ } // Create PR - fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_pr.creating")) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.ProgressSubject("create", "PR")) prURL, err := agentic.CreatePR(ctx, task, cwd, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create PR"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.create", "PR"), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_pr.created")) - fmt.Printf(" %s %s\n", i18n.T("common.label.url"), prURL) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.create", "PR")) + fmt.Printf(" %s %s\n", i18n.Label("url"), prURL) return nil }, diff --git a/pkg/ai/cmd_tasks.go b/pkg/ai/cmd_tasks.go index 05edb33..f7e1cc2 100644 --- a/pkg/ai/cmd_tasks.go +++ b/pkg/ai/cmd_tasks.go @@ -43,7 +43,7 @@ var tasksCmd = &cobra.Command{ cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -68,7 +68,7 @@ var tasksCmd = &cobra.Command{ tasks, err := client.ListTasks(ctx, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list tasks"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.list", "tasks"), err) } if len(tasks) == 0 { @@ -88,7 +88,7 @@ var taskCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -111,7 +111,7 @@ var taskCmd = &cobra.Command{ Limit: 50, }) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list tasks"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.list", "tasks"), err) } if len(tasks) == 0 { @@ -140,7 +140,7 @@ var taskCmd = &cobra.Command{ task, err = client.GetTask(ctx, taskID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "task"), err) } } @@ -149,7 +149,7 @@ var taskCmd = &cobra.Command{ cwd, _ := os.Getwd() taskCtx, err := agentic.BuildTaskContext(task, cwd) if err != nil { - fmt.Printf("%s %s: %s\n", errorStyle.Render(">>"), i18n.T("common.error.failed", map[string]any{"Action": "build context"}), err) + fmt.Printf("%s %s: %s\n", errorStyle.Render(">>"), i18n.T("i18n.fail.build", "context"), err) } else { fmt.Println(taskCtx.FormatContext()) } @@ -163,11 +163,11 @@ var taskCmd = &cobra.Command{ claimedTask, err := client.ClaimTask(ctx, task.ID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "claim task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.claim", "task"), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task claimed"})) - fmt.Printf(" %s %s\n", i18n.T("common.label.status"), formatTaskStatus(claimedTask.Status)) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.claim", "task")) + fmt.Printf(" %s %s\n", i18n.Label("status"), formatTaskStatus(claimedTask.Status)) } return nil @@ -225,10 +225,10 @@ func printTaskDetails(task *agentic.Task) { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.ai.label.id")), taskIDStyle.Render(task.ID)) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.ai.label.title")), taskTitleStyle.Render(task.Title)) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.ai.label.priority")), formatTaskPriority(task.Priority)) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.status")), formatTaskStatus(task.Status)) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("status")), formatTaskStatus(task.Status)) if task.Project != "" { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.project")), task.Project) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("project")), task.Project) } if len(task.Labels) > 0 { diff --git a/pkg/ai/cmd_updates.go b/pkg/ai/cmd_updates.go index b43974b..30135a1 100644 --- a/pkg/ai/cmd_updates.go +++ b/pkg/ai/cmd_updates.go @@ -40,7 +40,7 @@ var taskUpdateCmd = &cobra.Command{ cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -57,10 +57,10 @@ var taskUpdateCmd = &cobra.Command{ } if err := client.UpdateTask(ctx, taskID, update); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "update task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.update", "task"), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task updated"})) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.update", "task")) return nil }, } @@ -75,7 +75,7 @@ var taskCompleteCmd = &cobra.Command{ cfg, err := agentic.LoadConfig("") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } client := agentic.NewClientFromConfig(cfg) @@ -90,13 +90,13 @@ var taskCompleteCmd = &cobra.Command{ } if err := client.CompleteTask(ctx, taskID, result); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "complete task"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.complete", "task"), err) } if taskCompleteFailed { fmt.Printf("%s %s\n", errorStyle.Render(">>"), i18n.T("cmd.ai.task_complete.failed", map[string]interface{}{"ID": taskID})) } else { - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task completed"})) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.complete", "task")) } return nil }, diff --git a/pkg/ci/cmd_changelog.go b/pkg/ci/cmd_changelog.go index 90e5e5d..dd8ab59 100644 --- a/pkg/ci/cmd_changelog.go +++ b/pkg/ci/cmd_changelog.go @@ -12,19 +12,19 @@ import ( func runChangelog(fromRef, toRef string) error { projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Load config for changelog settings cfg, err := release.LoadConfig(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } // Generate changelog changelog, err := release.GenerateWithConfig(projectDir, fromRef, toRef, &cfg.Changelog) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "generate changelog"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.generate", "changelog"), err) } fmt.Println(changelog) diff --git a/pkg/ci/cmd_init.go b/pkg/ci/cmd_init.go index 445c45b..a5298b1 100644 --- a/pkg/ci/cmd_init.go +++ b/pkg/ci/cmd_init.go @@ -15,13 +15,13 @@ import ( func runCIReleaseInit() error { projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Check if config already exists if release.ConfigExists(projectDir) { fmt.Printf("%s %s %s\n", - releaseDimStyle.Render(i18n.T("common.label.note")), + releaseDimStyle.Render(i18n.Label("note")), i18n.T("cmd.ci.init.config_exists"), release.ConfigPath(projectDir)) @@ -61,12 +61,12 @@ func runCIReleaseInit() error { // Write config if err := release.WriteConfig(cfg, projectDir); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "write config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.write", "config"), err) } fmt.Println() fmt.Printf("%s %s %s\n", - releaseSuccessStyle.Render(i18n.T("common.label.success")), + releaseSuccessStyle.Render(i18n.T("i18n.done.pass")), i18n.T("cmd.ci.init.config_written"), release.ConfigPath(projectDir)) diff --git a/pkg/ci/cmd_publish.go b/pkg/ci/cmd_publish.go index 2f7e62a..83709f2 100644 --- a/pkg/ci/cmd_publish.go +++ b/pkg/ci/cmd_publish.go @@ -18,13 +18,13 @@ func runCIPublish(dryRun bool, version string, draft, prerelease bool) error { // Get current directory projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Load configuration cfg, err := release.LoadConfig(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "config"), err) } // Apply CLI overrides @@ -61,14 +61,14 @@ func runCIPublish(dryRun bool, version string, draft, prerelease bool) error { // Publish pre-built artifacts rel, err := release.Publish(ctx, cfg, dryRun) if err != nil { - fmt.Printf("%s %v\n", releaseErrorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %v\n", releaseErrorStyle.Render(i18n.Label("error")), err) return err } // Print summary fmt.Println() - fmt.Printf("%s %s\n", releaseSuccessStyle.Render(i18n.T("common.label.success")), i18n.T("cmd.ci.publish_completed")) - fmt.Printf(" %s %s\n", i18n.T("common.label.version"), releaseValueStyle.Render(rel.Version)) + fmt.Printf("%s %s\n", releaseSuccessStyle.Render(i18n.T("i18n.done.pass")), i18n.T("cmd.ci.publish_completed")) + fmt.Printf(" %s %s\n", i18n.Label("version"), releaseValueStyle.Render(rel.Version)) fmt.Printf(" %s %d\n", i18n.T("cmd.ci.label.artifacts"), len(rel.Artifacts)) if !dryRun { diff --git a/pkg/ci/cmd_version.go b/pkg/ci/cmd_version.go index 00da9e9..8d59f98 100644 --- a/pkg/ci/cmd_version.go +++ b/pkg/ci/cmd_version.go @@ -12,14 +12,14 @@ import ( func runCIReleaseVersion() error { projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } version, err := release.DetermineVersion(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "determine version"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.determine", "version"), err) } - fmt.Printf("%s %s\n", i18n.T("common.label.version"), releaseValueStyle.Render(version)) + fmt.Printf("%s %s\n", i18n.Label("version"), releaseValueStyle.Render(version)) return nil } diff --git a/pkg/dev/cmd_ci.go b/pkg/dev/cmd_ci.go index 90d9aac..a07a868 100644 --- a/pkg/dev/cmd_ci.go +++ b/pkg/dev/cmd_ci.go @@ -183,7 +183,7 @@ func runCI(registryPath string, branch string, failedOnly bool) error { if len(fetchErrors) > 0 { fmt.Println() for _, err := range fetchErrors { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("error")), err) } } diff --git a/pkg/dev/cmd_commit.go b/pkg/dev/cmd_commit.go index 0cc54bd..a50067e 100644 --- a/pkg/dev/cmd_commit.go +++ b/pkg/dev/cmd_commit.go @@ -54,7 +54,7 @@ func runCommit(registryPath string, all bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { registryPath, err = repos.FindRegistry() if err == nil { @@ -62,7 +62,7 @@ func runCommit(registryPath string, all bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { // Fallback: scan current directory for repos reg, err = repos.ScanDirectory(cwd) diff --git a/pkg/dev/cmd_impact.go b/pkg/dev/cmd_impact.go index d2675f7..b348322 100644 --- a/pkg/dev/cmd_impact.go +++ b/pkg/dev/cmd_impact.go @@ -139,7 +139,7 @@ func runImpact(registryPath string, repoName string) error { // Summary fmt.Printf("%s %s\n", - dimStyle.Render(i18n.T("common.label.summary")), + dimStyle.Render(i18n.Label("summary")), i18n.T("cmd.dev.impact.changes_affect", map[string]interface{}{ "Repo": repoNameStyle.Render(repoName), "Affected": len(allAffected), diff --git a/pkg/dev/cmd_issues.go b/pkg/dev/cmd_issues.go index ceaaf30..094e908 100644 --- a/pkg/dev/cmd_issues.go +++ b/pkg/dev/cmd_issues.go @@ -151,7 +151,7 @@ func runIssues(registryPath string, limit int, assignee string) error { if len(fetchErrors) > 0 { fmt.Println() for _, err := range fetchErrors { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("error")), err) } } diff --git a/pkg/dev/cmd_pull.go b/pkg/dev/cmd_pull.go index c66d8d0..ec254fe 100644 --- a/pkg/dev/cmd_pull.go +++ b/pkg/dev/cmd_pull.go @@ -47,7 +47,7 @@ func runPull(registryPath string, all bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { registryPath, err = repos.FindRegistry() if err == nil { @@ -55,7 +55,7 @@ func runPull(registryPath string, all bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { // Fallback: scan current directory cwd, _ := os.Getwd() diff --git a/pkg/dev/cmd_push.go b/pkg/dev/cmd_push.go index a7e1307..ec53f5f 100644 --- a/pkg/dev/cmd_push.go +++ b/pkg/dev/cmd_push.go @@ -54,7 +54,7 @@ func runPush(registryPath string, force bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { registryPath, err = repos.FindRegistry() if err == nil { @@ -62,7 +62,7 @@ func runPush(registryPath string, force bool) error { if err != nil { return fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { // Fallback: scan current directory for repos reg, err = repos.ScanDirectory(cwd) diff --git a/pkg/dev/cmd_reviews.go b/pkg/dev/cmd_reviews.go index 9ff2dff..7a4ff47 100644 --- a/pkg/dev/cmd_reviews.go +++ b/pkg/dev/cmd_reviews.go @@ -186,7 +186,7 @@ func runReviews(registryPath string, author string, showAll bool) error { if len(fetchErrors) > 0 { fmt.Println() for _, err := range fetchErrors { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("error")), err) } } diff --git a/pkg/dev/cmd_sync.go b/pkg/dev/cmd_sync.go index 5eec722..2c96c52 100644 --- a/pkg/dev/cmd_sync.go +++ b/pkg/dev/cmd_sync.go @@ -24,9 +24,9 @@ func addSyncCommand(parent *cobra.Command) { Long: i18n.T("cmd.dev.sync.long"), RunE: func(cmd *cobra.Command, args []string) error { if err := runSync(); err != nil { - return fmt.Errorf("%s %w", i18n.T("common.label.error"), err) + return fmt.Errorf("%s %w", i18n.Label("error"), err) } - fmt.Println(i18n.T("common.success.completed", map[string]any{"Action": "Public APIs synchronized"})) + fmt.Println(i18n.T("i18n.done.sync", "public APIs")) return nil }, } diff --git a/pkg/dev/cmd_vm.go b/pkg/dev/cmd_vm.go index 7590e4f..156320b 100644 --- a/pkg/dev/cmd_vm.go +++ b/pkg/dev/cmd_vm.go @@ -53,7 +53,7 @@ func runVMInstall() error { return nil } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.image")), devops.ImageName()) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("image")), devops.ImageName()) fmt.Println() fmt.Println(i18n.T("cmd.dev.vm.downloading")) fmt.Println() @@ -223,7 +223,7 @@ func runVMStatus() error { if status.Installed { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.dev.vm.installed_label")), successStyle.Render(i18n.T("cmd.dev.vm.installed_yes"))) if status.ImageVersion != "" { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.version")), status.ImageVersion) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("version")), status.ImageVersion) } } else { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.dev.vm.installed_label")), errorStyle.Render(i18n.T("cmd.dev.vm.installed_no"))) @@ -236,14 +236,14 @@ func runVMStatus() error { // Running status if status.Running { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.status")), successStyle.Render(i18n.T("common.status.running"))) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("status")), successStyle.Render(i18n.T("common.status.running"))) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.dev.vm.container_label")), status.ContainerID[:8]) fmt.Printf("%s %dMB\n", dimStyle.Render(i18n.T("cmd.dev.vm.memory_label")), status.Memory) fmt.Printf("%s %d\n", dimStyle.Render(i18n.T("cmd.dev.vm.cpus_label")), status.CPUs) fmt.Printf("%s %d\n", dimStyle.Render(i18n.T("cmd.dev.vm.ssh_port")), status.SSHPort) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.dev.vm.uptime_label")), formatVMUptime(status.Uptime)) } else { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.status")), dimStyle.Render(i18n.T("common.status.stopped"))) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("status")), dimStyle.Render(i18n.T("common.status.stopped"))) fmt.Println() fmt.Println(i18n.T("cmd.dev.vm.start_with", map[string]interface{}{"Command": dimStyle.Render("core dev boot")})) } @@ -461,7 +461,7 @@ func runVMUpdate(apply bool) error { return fmt.Errorf("failed to check for updates: %w", err) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.current")), valueStyle.Render(current)) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("current")), valueStyle.Render(current)) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.dev.vm.latest_label")), valueStyle.Render(latest)) fmt.Println() diff --git a/pkg/dev/cmd_work.go b/pkg/dev/cmd_work.go index fb8f8d0..022a6f0 100644 --- a/pkg/dev/cmd_work.go +++ b/pkg/dev/cmd_work.go @@ -244,7 +244,7 @@ func printStatusTable(statuses []git.RepoStatus) { // Print header with fixed-width formatting fmt.Printf("%-*s %8s %9s %6s %5s\n", nameWidth, - cli.TitleStyle.Render(i18n.T("common.label.repo")), + cli.TitleStyle.Render(i18n.Label("repo")), cli.TitleStyle.Render(i18n.T("cmd.dev.work.table_modified")), cli.TitleStyle.Render(i18n.T("cmd.dev.work.table_untracked")), cli.TitleStyle.Render(i18n.T("cmd.dev.work.table_staged")), @@ -341,7 +341,7 @@ func loadRegistry(registryPath string) ([]string, map[string]string, error) { if err != nil { return nil, nil, fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { registryPath, err = repos.FindRegistry() if err == nil { @@ -349,7 +349,7 @@ func loadRegistry(registryPath string) ([]string, map[string]string, error) { if err != nil { return nil, nil, fmt.Errorf("failed to load registry: %w", err) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.Label("registry")), registryPath) } else { // Fallback: scan current directory cwd, _ := os.Getwd() diff --git a/pkg/docs/cmd_list.go b/pkg/docs/cmd_list.go index aa34403..a332364 100644 --- a/pkg/docs/cmd_list.go +++ b/pkg/docs/cmd_list.go @@ -32,7 +32,7 @@ func runDocsList(registryPath string) error { } fmt.Printf("\n%-20s %-8s %-8s %-10s %s\n", - headerStyle.Render(i18n.T("common.label.repo")), + headerStyle.Render(i18n.Label("repo")), headerStyle.Render(i18n.T("cmd.docs.list.header.readme")), headerStyle.Render(i18n.T("cmd.docs.list.header.claude")), headerStyle.Render(i18n.T("cmd.docs.list.header.changelog")), @@ -70,7 +70,7 @@ func runDocsList(registryPath string) error { fmt.Println() fmt.Printf("%s %s\n", - cli.Label(i18n.T("common.label.coverage")), + cli.Label(i18n.Label("coverage")), i18n.T("cmd.docs.list.coverage_summary", map[string]interface{}{"WithDocs": withDocs, "WithoutDocs": withoutDocs}), ) diff --git a/pkg/docs/cmd_scan.go b/pkg/docs/cmd_scan.go index f590474..3b3b243 100644 --- a/pkg/docs/cmd_scan.go +++ b/pkg/docs/cmd_scan.go @@ -30,7 +30,7 @@ func loadRegistry(registryPath string) (*repos.Registry, string, error) { if registryPath != "" { reg, err = repos.LoadRegistry(registryPath) if err != nil { - return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "registry"), err) } basePath = filepath.Dir(registryPath) } else { @@ -38,14 +38,14 @@ func loadRegistry(registryPath string) (*repos.Registry, string, error) { if err == nil { reg, err = repos.LoadRegistry(registryPath) if err != nil { - return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "registry"), err) } basePath = filepath.Dir(registryPath) } else { cwd, _ := os.Getwd() reg, err = repos.ScanDirectory(cwd) if err != nil { - return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "scan directory"}), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("i18n.fail.scan", "directory"), err) } basePath = cwd } diff --git a/pkg/docs/cmd_sync.go b/pkg/docs/cmd_sync.go index 27428dc..bd8a54d 100644 --- a/pkg/docs/cmd_sync.go +++ b/pkg/docs/cmd_sync.go @@ -105,7 +105,7 @@ func runDocsSync(registryPath string, outputDir string, dryRun bool) error { } fmt.Printf("\n%s %s\n", - dimStyle.Render(i18n.T("common.label.total")), + dimStyle.Render(i18n.Label("total")), i18n.T("cmd.docs.sync.total_summary", map[string]interface{}{"Files": totalFiles, "Repos": len(docsInfo), "Output": outputDir})) if dryRun { @@ -150,7 +150,7 @@ func runDocsSync(registryPath string, outputDir string, dryRun bool) error { synced++ } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.docs.sync.synced_packages", map[string]interface{}{"Count": synced})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("i18n.done.sync")), i18n.T("cmd.docs.sync.synced_packages", map[string]interface{}{"Count": synced})) return nil } diff --git a/pkg/php/cmd_build.go b/pkg/php/cmd_build.go index f086a31..8fd23f4 100644 --- a/pkg/php/cmd_build.go +++ b/pkg/php/cmd_build.go @@ -31,7 +31,7 @@ func addPHPBuildCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } ctx := context.Background() @@ -92,7 +92,7 @@ func runPHPBuildDocker(ctx context.Context, projectDir string, opts dockerBuildO // Show detected configuration config, err := DetectDockerfileConfig(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "detect project configuration"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.detect", "project configuration"), err) } fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.build.php_version")), config.PHPVersion) @@ -128,17 +128,17 @@ func runPHPBuildDocker(ctx context.Context, projectDir string, opts dockerBuildO buildOpts.Tag = "latest" } - fmt.Printf("%s %s:%s\n", dimStyle.Render(i18n.T("common.label.image")), buildOpts.ImageName, buildOpts.Tag) + fmt.Printf("%s %s:%s\n", dimStyle.Render(i18n.Label("image")), buildOpts.ImageName, buildOpts.Tag) if opts.Platform != "" { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.build.platform")), opts.Platform) } fmt.Println() if err := BuildDocker(ctx, buildOpts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.build"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "Docker image built"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "Docker image built"})) fmt.Printf("%s docker run -p 80:80 -p 443:443 %s:%s\n", dimStyle.Render(i18n.T("cmd.php.build.docker_run_with")), buildOpts.ImageName, buildOpts.Tag) @@ -168,15 +168,15 @@ func runPHPBuildLinuxKit(ctx context.Context, projectDir string, opts linuxKitBu buildOpts.Template = "server-php" } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.template")), buildOpts.Template) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("template")), buildOpts.Template) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.build.format")), buildOpts.Format) fmt.Println() if err := BuildLinuxKit(ctx, buildOpts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.build"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "LinuxKit image built"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "LinuxKit image built"})) return nil } @@ -224,8 +224,8 @@ func addPHPServeCommand(parent *cobra.Command) { Output: os.Stdout, } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("common.progress.running", map[string]any{"Task": "production container"})) - fmt.Printf("%s %s:%s\n", dimStyle.Render(i18n.T("common.label.image")), imageName, func() string { + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.ProgressSubject("run", "production container")) + fmt.Printf("%s %s:%s\n", dimStyle.Render(i18n.Label("image")), imageName, func() string { if serveTag == "" { return "latest" } @@ -246,7 +246,7 @@ func addPHPServeCommand(parent *cobra.Command) { fmt.Println() if err := ServeProduction(ctx, opts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "start container"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.start", "container"), err) } if !serveDetach { @@ -280,7 +280,7 @@ func addPHPShellCommand(parent *cobra.Command) { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.shell.opening", map[string]interface{}{"Container": args[0]})) if err := Shell(ctx, args[0]); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "open shell"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.open", "shell"), err) } return nil diff --git a/pkg/php/cmd_deploy.go b/pkg/php/cmd_deploy.go index c48c25b..07ebbc8 100644 --- a/pkg/php/cmd_deploy.go +++ b/pkg/php/cmd_deploy.go @@ -46,7 +46,7 @@ func addPHPDeployCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } env := EnvProduction @@ -74,12 +74,12 @@ func addPHPDeployCommand(parent *cobra.Command) { if deployWait { if IsDeploymentSuccessful(status.Status) { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "Deployment completed"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "Deployment completed"})) } else { - fmt.Printf("\n%s %s\n", errorStyle.Render(i18n.T("common.label.warning")), i18n.T("cmd.php.deploy.warning_status", map[string]interface{}{"Status": status.Status})) + fmt.Printf("\n%s %s\n", errorStyle.Render(i18n.Label("warning")), i18n.T("cmd.php.deploy.warning_status", map[string]interface{}{"Status": status.Status})) } } else { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.deploy.triggered")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.deploy.triggered")) } return nil @@ -106,7 +106,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } env := EnvProduction @@ -114,7 +114,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) { env = EnvStaging } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.deploy")), i18n.T("common.progress.checking", map[string]any{"Item": "deployment status"})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.deploy")), i18n.ProgressSubject("check", "deployment status")) ctx := context.Background() @@ -126,7 +126,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) { status, err := DeployStatus(ctx, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get status"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "status"), err) } printDeploymentStatus(status) @@ -155,7 +155,7 @@ func addPHPDeployRollbackCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } env := EnvProduction @@ -183,12 +183,12 @@ func addPHPDeployRollbackCommand(parent *cobra.Command) { if rollbackWait { if IsDeploymentSuccessful(status.Status) { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "Rollback completed"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "Rollback completed"})) } else { - fmt.Printf("\n%s %s\n", errorStyle.Render(i18n.T("common.label.warning")), i18n.T("cmd.php.deploy_rollback.warning_status", map[string]interface{}{"Status": status.Status})) + fmt.Printf("\n%s %s\n", errorStyle.Render(i18n.Label("warning")), i18n.T("cmd.php.deploy_rollback.warning_status", map[string]interface{}{"Status": status.Status})) } } else { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.deploy_rollback.triggered")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.deploy_rollback.triggered")) } return nil @@ -215,7 +215,7 @@ func addPHPDeployListCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } env := EnvProduction @@ -234,7 +234,7 @@ func addPHPDeployListCommand(parent *cobra.Command) { deployments, err := ListDeployments(ctx, cwd, env, limit) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list deployments"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.list", "deployments"), err) } if len(deployments) == 0 { @@ -266,14 +266,14 @@ func printDeploymentStatus(status *DeploymentStatus) { statusStyle = phpDeployFailedStyle } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.status")), statusStyle.Render(status.Status)) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("status")), statusStyle.Render(status.Status)) if status.ID != "" { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.id")), status.ID) } if status.URL != "" { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.url")), linkStyle.Render(status.URL)) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("url")), linkStyle.Render(status.URL)) } if status.Branch != "" { @@ -297,7 +297,7 @@ func printDeploymentStatus(status *DeploymentStatus) { } if !status.StartedAt.IsZero() { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.started")), status.StartedAt.Format(time.RFC3339)) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("started")), status.StartedAt.Format(time.RFC3339)) } if !status.CompletedAt.IsZero() { diff --git a/pkg/php/cmd_dev.go b/pkg/php/cmd_dev.go index 6086576..aa8dc36 100644 --- a/pkg/php/cmd_dev.go +++ b/pkg/php/cmd_dev.go @@ -126,7 +126,7 @@ func runPHPDev(opts phpDevOptions) error { }() if err := server.Start(ctx, devOpts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "start services"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.start", "services"), err) } // Print status @@ -155,7 +155,7 @@ func runPHPDev(opts phpDevOptions) error { // Stream unified logs logsReader, err := server.Logs("", true) if err != nil { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.warning")), i18n.T("common.error.failed", map[string]any{"Action": "get logs"})) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("warning")), i18n.T("i18n.fail.get", "logs")) } else { defer logsReader.Close() @@ -174,10 +174,10 @@ func runPHPDev(opts phpDevOptions) error { shutdown: // Stop services if err := server.Stop(); err != nil { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.php.dev.stop_error", map[string]interface{}{"Error": err})) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("error")), i18n.T("cmd.php.dev.stop_error", map[string]interface{}{"Error": err})) } - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.dev.all_stopped")) + fmt.Printf("%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.dev.all_stopped")) return nil } @@ -217,7 +217,7 @@ func runPHPLogs(service string, follow bool) error { logsReader, err := server.Logs(service, follow) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get logs"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "logs"), err) } defer logsReader.Close() @@ -270,10 +270,10 @@ func runPHPStop() error { // This is a simplified version - in practice you'd want to track PIDs server := NewDevServer(Options{Dir: cwd}) if err := server.Stop(); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "stop services"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.stop", "services"), err) } - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.dev.all_stopped")) + fmt.Printf("%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.dev.all_stopped")) return nil } @@ -304,7 +304,7 @@ func runPHPStatus() error { appName = "Laravel" } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("common.label.project")), appName) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.Label("project")), appName) // Detect available services services := DetectServices(cwd) @@ -373,7 +373,7 @@ func runPHPSSL(domain string) error { // Check if mkcert is installed if !IsMkcertInstalled() { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.php.ssl.mkcert_not_installed")) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("error")), i18n.T("cmd.php.ssl.mkcert_not_installed")) fmt.Printf("\n%s\n", i18n.T("common.hint.install_with")) fmt.Printf(" %s\n", i18n.T("cmd.php.ssl.install_macos")) fmt.Printf(" %s\n", i18n.T("cmd.php.ssl.install_linux")) @@ -384,7 +384,7 @@ func runPHPSSL(domain string) error { // Check if certs already exist if CertsExist(domain, SSLOptions{}) { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.skip")), i18n.T("cmd.php.ssl.certs_exist")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("skip")), i18n.T("cmd.php.ssl.certs_exist")) certFile, keyFile, _ := CertPaths(domain, SSLOptions{}) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.ssl.cert_label")), certFile) @@ -394,12 +394,12 @@ func runPHPSSL(domain string) error { // Setup SSL if err := SetupSSL(domain, SSLOptions{}); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "setup SSL"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.setup", "SSL"), err) } certFile, keyFile, _ := CertPaths(domain, SSLOptions{}) - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.ssl.certs_created")) + fmt.Printf("%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.ssl.certs_created")) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.ssl.cert_label")), certFile) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.ssl.key_label")), keyFile) diff --git a/pkg/php/cmd_packages.go b/pkg/php/cmd_packages.go index b587088..f01a568 100644 --- a/pkg/php/cmd_packages.go +++ b/pkg/php/cmd_packages.go @@ -31,16 +31,16 @@ func addPHPPackagesLinkCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.link.linking")) if err := LinkPackages(cwd, args); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "link packages"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.link", "packages"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.packages.link.done")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.packages.link.done")) return nil }, } @@ -57,16 +57,16 @@ func addPHPPackagesUnlinkCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.unlink.unlinking")) if err := UnlinkPackages(cwd, args); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "unlink packages"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.unlink", "packages"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.packages.unlink.done")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.packages.unlink.done")) return nil }, } @@ -82,7 +82,7 @@ func addPHPPackagesUpdateCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.update.updating")) @@ -91,7 +91,7 @@ func addPHPPackagesUpdateCommand(parent *cobra.Command) { return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.update_packages"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.packages.update.done")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.packages.update.done")) return nil }, } @@ -107,12 +107,12 @@ func addPHPPackagesListCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } packages, err := ListLinkedPackages(cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list packages"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.list", "packages"), err) } if len(packages) == 0 { @@ -133,8 +133,8 @@ func addPHPPackagesListCommand(parent *cobra.Command) { } fmt.Printf(" %s %s\n", successStyle.Render("*"), name) - fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("common.label.path")), pkg.Path) - fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("common.label.version")), version) + fmt.Printf(" %s %s\n", dimStyle.Render(i18n.Label("path")), pkg.Path) + fmt.Printf(" %s %s\n", dimStyle.Render(i18n.Label("version")), version) fmt.Println() } diff --git a/pkg/php/cmd_quality.go b/pkg/php/cmd_quality.go index b1045d2..7b073b8 100644 --- a/pkg/php/cmd_quality.go +++ b/pkg/php/cmd_quality.go @@ -27,14 +27,14 @@ func addPHPTestCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { return errors.New(i18n.T("cmd.php.error.not_php")) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("common.progress.running", map[string]any{"Task": "tests"})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.ProgressSubject("run", "tests")) ctx := context.Background() @@ -51,7 +51,7 @@ func addPHPTestCommand(parent *cobra.Command) { } if err := RunTests(ctx, opts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "run tests"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.run", "tests"), err) } return nil @@ -79,7 +79,7 @@ func addPHPFmtCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -96,7 +96,7 @@ func addPHPFmtCommand(parent *cobra.Command) { if fmtFix { msg = i18n.T("cmd.php.fmt.formatting", map[string]interface{}{"Formatter": formatter}) } else { - msg = i18n.T("common.progress.checking", map[string]any{"Item": "code style"}) + msg = i18n.ProgressSubject("check", "code style") } fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), msg) @@ -122,9 +122,9 @@ func addPHPFmtCommand(parent *cobra.Command) { } if fmtFix { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "Code formatted"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "Code formatted"})) } else { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.fmt.no_issues")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.fmt.no_issues")) } return nil @@ -150,7 +150,7 @@ func addPHPStanCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -163,7 +163,7 @@ func addPHPStanCommand(parent *cobra.Command) { return errors.New(i18n.T("cmd.php.analyse.no_analyser")) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("common.progress.running", map[string]any{"Task": "static analysis"})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.ProgressSubject("run", "static analysis")) ctx := context.Background() @@ -183,7 +183,7 @@ func addPHPStanCommand(parent *cobra.Command) { return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.analysis_issues"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.result.no_issues")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.result.no_issues")) return nil }, } @@ -213,7 +213,7 @@ func addPHPPsalmCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -223,8 +223,8 @@ func addPHPPsalmCommand(parent *cobra.Command) { // Check if Psalm is available _, found := DetectPsalm(cwd) if !found { - fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.php.psalm.not_found")) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.install")), i18n.T("cmd.php.psalm.install")) + fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.Label("error")), i18n.T("cmd.php.psalm.not_found")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("install")), i18n.T("cmd.php.psalm.install")) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.setup")), i18n.T("cmd.php.psalm.setup")) return errors.New(i18n.T("cmd.php.error.psalm_not_installed")) } @@ -252,7 +252,7 @@ func addPHPPsalmCommand(parent *cobra.Command) { return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.psalm_issues"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.result.no_issues")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.result.no_issues")) return nil }, } @@ -278,7 +278,7 @@ func addPHPAuditCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -336,8 +336,8 @@ func addPHPAuditCommand(parent *cobra.Command) { fmt.Println() if totalVulns > 0 { - fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.warning")), i18n.T("cmd.php.audit.found_vulns", map[string]interface{}{"Count": totalVulns})) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.fix")), i18n.T("common.hint.fix_deps")) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.Label("warning")), i18n.T("cmd.php.audit.found_vulns", map[string]interface{}{"Count": totalVulns})) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("fix")), i18n.T("common.hint.fix_deps")) return errors.New(i18n.T("cmd.php.error.vulns_found")) } @@ -345,7 +345,7 @@ func addPHPAuditCommand(parent *cobra.Command) { return errors.New(i18n.T("cmd.php.audit.completed_errors")) } - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.audit.all_secure")) + fmt.Printf("%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.audit.all_secure")) return nil }, } @@ -371,14 +371,14 @@ func addPHPSecurityCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { return errors.New(i18n.T("cmd.php.error.not_php")) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.security")), i18n.T("common.progress.running", map[string]any{"Task": "security checks"})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.security")), i18n.ProgressSubject("run", "security checks")) ctx := context.Background() @@ -415,7 +415,7 @@ func addPHPSecurityCommand(parent *cobra.Command) { if !check.Passed && check.Message != "" { fmt.Printf(" %s\n", dimStyle.Render(check.Message)) if check.Fix != "" { - fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("common.label.fix")), check.Fix) + fmt.Printf(" %s %s\n", dimStyle.Render(i18n.Label("fix")), check.Fix) } } } @@ -423,7 +423,7 @@ func addPHPSecurityCommand(parent *cobra.Command) { fmt.Println() // Print summary - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.summary")), i18n.T("cmd.php.security.summary")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("summary")), i18n.T("cmd.php.security.summary")) fmt.Printf(" %s %d/%d\n", dimStyle.Render(i18n.T("cmd.php.security.passed")), result.Summary.Passed, result.Summary.Total) if result.Summary.Critical > 0 { @@ -469,7 +469,7 @@ func addPHPQACommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -493,13 +493,13 @@ func addPHPQACommand(parent *cobra.Command) { // Create QA runner using pkg/process runner, err := NewQARunner(cwd, qaFix) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create QA runner"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.create", "QA runner"), err) } // Run all checks with dependency ordering result, err := runner.Run(ctx, stages) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "run QA checks"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.run", "QA checks"), err) } // Display results by stage @@ -619,7 +619,7 @@ func addPHPRectorCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -628,8 +628,8 @@ func addPHPRectorCommand(parent *cobra.Command) { // Check if Rector is available if !DetectRector(cwd) { - fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.php.rector.not_found")) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.install")), i18n.T("cmd.php.rector.install")) + fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.Label("error")), i18n.T("cmd.php.rector.not_found")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("install")), i18n.T("cmd.php.rector.install")) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.setup")), i18n.T("cmd.php.rector.setup")) return errors.New(i18n.T("cmd.php.error.rector_not_installed")) } @@ -662,9 +662,9 @@ func addPHPRectorCommand(parent *cobra.Command) { } if rectorFix { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("common.success.completed", map[string]any{"Action": "Code refactored"})) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("common.success.completed", map[string]any{"Action": "Code refactored"})) } else { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.rector.no_changes")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.rector.no_changes")) } return nil }, @@ -693,7 +693,7 @@ func addPHPInfectionCommand(parent *cobra.Command) { RunE: func(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } if !IsPHPProject(cwd) { @@ -702,12 +702,12 @@ func addPHPInfectionCommand(parent *cobra.Command) { // Check if Infection is available if !DetectInfection(cwd) { - fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.php.infection.not_found")) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.install")), i18n.T("cmd.php.infection.install")) + fmt.Printf("%s %s\n\n", errorStyle.Render(i18n.Label("error")), i18n.T("cmd.php.infection.not_found")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("install")), i18n.T("cmd.php.infection.install")) return errors.New(i18n.T("cmd.php.error.infection_not_installed")) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.infection")), i18n.T("common.progress.running", map[string]any{"Task": "mutation testing"})) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.infection")), i18n.ProgressSubject("run", "mutation testing")) fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.info")), i18n.T("cmd.php.infection.note")) ctx := context.Background() @@ -726,7 +726,7 @@ func addPHPInfectionCommand(parent *cobra.Command) { return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.infection_failed"), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.infection.complete")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.Label("done")), i18n.T("cmd.php.infection.complete")) return nil }, } diff --git a/pkg/pkgcmd/cmd_install.go b/pkg/pkgcmd/cmd_install.go index f10342c..08bf87c 100644 --- a/pkg/pkgcmd/cmd_install.go +++ b/pkg/pkgcmd/cmd_install.go @@ -74,16 +74,16 @@ func runPkgInstall(repoArg, targetDir string, addToRegistry bool) error { repoPath := filepath.Join(targetDir, repoName) if _, err := os.Stat(filepath.Join(repoPath, ".git")); err == nil { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.skip")), i18n.T("cmd.pkg.install.already_exists", map[string]string{"Name": repoName, "Path": repoPath})) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("skip")), i18n.T("cmd.pkg.install.already_exists", map[string]string{"Name": repoName, "Path": repoPath})) return nil } if err := os.MkdirAll(targetDir, 0755); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.create", "directory"), err) } fmt.Printf("%s %s/%s\n", dimStyle.Render(i18n.T("cmd.pkg.install.installing_label")), org, repoName) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.target")), repoPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("target")), repoPath) fmt.Println() fmt.Printf(" %s... ", dimStyle.Render(i18n.T("common.status.cloning"))) @@ -103,7 +103,7 @@ func runPkgInstall(repoArg, targetDir string, addToRegistry bool) error { } fmt.Println() - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.pkg.install.installed", map[string]string{"Name": repoName})) + fmt.Printf("%s %s\n", successStyle.Render(i18n.T("i18n.done.install")), i18n.T("cmd.pkg.install.installed", map[string]string{"Name": repoName})) return nil } diff --git a/pkg/pkgcmd/cmd_manage.go b/pkg/pkgcmd/cmd_manage.go index 8e4e3e1..d7f1bb9 100644 --- a/pkg/pkgcmd/cmd_manage.go +++ b/pkg/pkgcmd/cmd_manage.go @@ -35,7 +35,7 @@ func runPkgList() error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "registry"), err) } basePath := reg.BasePath @@ -83,7 +83,7 @@ func runPkgList() error { } fmt.Println() - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.total")), i18n.T("cmd.pkg.list.summary", map[string]int{"Installed": installed, "Missing": missing})) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("total")), i18n.T("cmd.pkg.list.summary", map[string]int{"Installed": installed, "Missing": missing})) if missing > 0 { fmt.Printf("\n%s %s\n", i18n.T("cmd.pkg.list.install_missing"), dimStyle.Render("core setup")) @@ -121,7 +121,7 @@ func runPkgUpdate(packages []string, all bool) error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "registry"), err) } basePath := reg.BasePath @@ -174,7 +174,7 @@ func runPkgUpdate(packages []string, all bool) error { fmt.Println() fmt.Printf("%s %s\n", - dimStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.pkg.update.summary", map[string]int{"Updated": updated, "Skipped": skipped, "Failed": failed})) + dimStyle.Render(i18n.T("i18n.done.update")), i18n.T("cmd.pkg.update.summary", map[string]int{"Updated": updated, "Skipped": skipped, "Failed": failed})) return nil } @@ -201,7 +201,7 @@ func runPkgOutdated() error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.load", "registry"), err) } basePath := reg.BasePath @@ -246,10 +246,10 @@ func runPkgOutdated() error { fmt.Println() if outdated == 0 { - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.pkg.outdated.all_up_to_date")) + fmt.Printf("%s %s\n", successStyle.Render(i18n.T("i18n.done.update")), i18n.T("cmd.pkg.outdated.all_up_to_date")) } else { fmt.Printf("%s %s\n", - dimStyle.Render(i18n.T("common.label.summary")), i18n.T("cmd.pkg.outdated.summary", map[string]int{"Outdated": outdated, "UpToDate": upToDate})) + dimStyle.Render(i18n.Label("summary")), i18n.T("cmd.pkg.outdated.summary", map[string]int{"Outdated": outdated, "UpToDate": upToDate})) fmt.Printf("\n%s %s\n", i18n.T("cmd.pkg.outdated.update_with"), dimStyle.Render("core pkg update --all")) } diff --git a/pkg/pkgcmd/cmd_search.go b/pkg/pkgcmd/cmd_search.go index 02e1eae..c672ca7 100644 --- a/pkg/pkgcmd/cmd_search.go +++ b/pkg/pkgcmd/cmd_search.go @@ -98,7 +98,7 @@ func runPkgSearch(org, pattern, repoType string, limit int, refresh bool) error } if os.Getenv("GH_TOKEN") != "" { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.note")), i18n.T("cmd.pkg.search.gh_token_warning")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("note")), i18n.T("cmd.pkg.search.gh_token_warning")) fmt.Printf("%s %s\n\n", dimStyle.Render(""), i18n.T("cmd.pkg.search.gh_token_unset")) } @@ -119,7 +119,7 @@ func runPkgSearch(org, pattern, repoType string, limit int, refresh bool) error } if err := json.Unmarshal(output, &ghRepos); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "parse results"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.parse", "results"), err) } if c != nil { diff --git a/pkg/sdk/cmd_sdk.go b/pkg/sdk/cmd_sdk.go index f4926f2..1854ef1 100644 --- a/pkg/sdk/cmd_sdk.go +++ b/pkg/sdk/cmd_sdk.go @@ -73,7 +73,7 @@ func AddSDKCommands(root *cobra.Command) { func runSDKDiff(basePath, specPath string) error { projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } // Detect current spec if not provided @@ -89,14 +89,14 @@ func runSDKDiff(basePath, specPath string) error { return errors.New(i18n.T("cmd.sdk.diff.error.base_required")) } - fmt.Printf("%s %s\n", sdkHeaderStyle.Render(i18n.T("cmd.sdk.diff.label")), i18n.T("common.progress.checking", map[string]any{"Item": "breaking changes"})) + fmt.Printf("%s %s\n", sdkHeaderStyle.Render(i18n.T("cmd.sdk.diff.label")), i18n.ProgressSubject("check", "breaking changes")) fmt.Printf(" %s %s\n", i18n.T("cmd.sdk.diff.base_label"), sdkDimStyle.Render(basePath)) - fmt.Printf(" %s %s\n", i18n.T("common.label.current"), sdkDimStyle.Render(specPath)) + fmt.Printf(" %s %s\n", i18n.Label("current"), sdkDimStyle.Render(specPath)) fmt.Println() result, err := Diff(basePath, specPath) if err != nil { - fmt.Printf("%s %v\n", sdkErrorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %v\n", sdkErrorStyle.Render(i18n.Label("error")), err) os.Exit(2) } @@ -115,7 +115,7 @@ func runSDKDiff(basePath, specPath string) error { func runSDKValidate(specPath string) error { projectDir, err := os.Getwd() if err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.get", "working directory"), err) } s := New(projectDir, &Config{Spec: specPath}) @@ -124,11 +124,11 @@ func runSDKValidate(specPath string) error { detectedPath, err := s.DetectSpec() if err != nil { - fmt.Printf("%s %v\n", sdkErrorStyle.Render(i18n.T("common.label.error")), err) + fmt.Printf("%s %v\n", sdkErrorStyle.Render(i18n.Label("error")), err) return err } - fmt.Printf(" %s %s\n", i18n.T("common.label.spec"), sdkDimStyle.Render(detectedPath)) + fmt.Printf(" %s %s\n", i18n.Label("spec"), sdkDimStyle.Render(detectedPath)) fmt.Printf("%s %s\n", sdkSuccessStyle.Render(i18n.T("cmd.sdk.label.ok")), i18n.T("cmd.sdk.validate.valid")) return nil } diff --git a/pkg/setup/cmd_registry.go b/pkg/setup/cmd_registry.go index 31a108c..be57c26 100644 --- a/pkg/setup/cmd_registry.go +++ b/pkg/setup/cmd_registry.go @@ -30,7 +30,7 @@ func runRegistrySetup(ctx context.Context, registryPath, only string, dryRun, al // runRegistrySetupWithReg runs setup with an already-loaded registry. func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryPath, only string, dryRun, all, runBuild bool) error { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.registry")), registryPath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("registry")), registryPath) fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.setup.org_label")), reg.Org) // Determine base path for cloning @@ -48,7 +48,7 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP basePath = filepath.Join(home, basePath[2:]) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.target")), basePath) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("target")), basePath) // Parse type filter var typeFilter []string @@ -56,7 +56,7 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP for _, t := range strings.Split(only, ",") { typeFilter = append(typeFilter, strings.TrimSpace(t)) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.filter")), only) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("filter")), only) } // Ensure base path exists @@ -188,9 +188,9 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP // Summary fmt.Println() - fmt.Printf("%s %s", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.setup.cloned_count", map[string]interface{}{"Count": succeeded})) + fmt.Printf("%s %s", successStyle.Render(i18n.Label("done")), i18n.T("cmd.setup.cloned_count", map[string]interface{}{"Count": succeeded})) if failed > 0 { - fmt.Printf(", %s", errorStyle.Render(i18n.T("common.count.failed", map[string]interface{}{"Count": failed}))) + fmt.Printf(", %s", errorStyle.Render(i18n.T("i18n.count.failed", failed))) } if exists > 0 { fmt.Printf(", %s", i18n.T("cmd.setup.already_exist_count", map[string]interface{}{"Count": exists})) @@ -200,13 +200,13 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP // Run build if requested if runBuild && succeeded > 0 { fmt.Println() - fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("common.progress.running", map[string]any{"Task": "build"})) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.ProgressSubject("run", "build")) buildCmd := exec.Command("core", "build") buildCmd.Dir = basePath buildCmd.Stdout = os.Stdout buildCmd.Stderr = os.Stderr if err := buildCmd.Run(); err != nil { - return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err) + return fmt.Errorf("%s: %w", i18n.T("i18n.fail.run", "build"), err) } } diff --git a/pkg/test/cmd_output.go b/pkg/test/cmd_output.go index 20c449b..303aa05 100644 --- a/pkg/test/cmd_output.go +++ b/pkg/test/cmd_output.go @@ -85,12 +85,12 @@ func printTestSummary(results testResults, showCoverage bool) { // Print pass/fail summary total := results.passed + results.failed if total > 0 { - fmt.Printf(" %s %s", testPassStyle.Render("✓"), i18n.T("common.count.passed", map[string]interface{}{"Count": results.passed})) + fmt.Printf(" %s %s", testPassStyle.Render("✓"), i18n.T("i18n.count.passed", results.passed)) if results.failed > 0 { - fmt.Printf(" %s %s", testFailStyle.Render("✗"), i18n.T("common.count.failed", map[string]interface{}{"Count": results.failed})) + fmt.Printf(" %s %s", testFailStyle.Render("✗"), i18n.T("i18n.count.failed", results.failed)) } if results.skipped > 0 { - fmt.Printf(" %s %s", testSkipStyle.Render("○"), i18n.T("common.count.skipped", map[string]interface{}{"Count": results.skipped})) + fmt.Printf(" %s %s", testSkipStyle.Render("○"), i18n.T("i18n.count.skipped", results.skipped)) } fmt.Println() } @@ -108,7 +108,7 @@ func printTestSummary(results testResults, showCoverage bool) { printCoverageSummary(results) } else if results.covCount > 0 { avgCov := results.totalCov / float64(results.covCount) - fmt.Printf("\n %s %s\n", i18n.T("common.label.coverage"), formatCoverage(avgCov)) + fmt.Printf("\n %s %s\n", i18n.Label("coverage"), formatCoverage(avgCov)) } } diff --git a/pkg/test/cmd_runner.go b/pkg/test/cmd_runner.go index a120ffc..027a59f 100644 --- a/pkg/test/cmd_runner.go +++ b/pkg/test/cmd_runner.go @@ -55,10 +55,10 @@ func runTest(verbose, coverage, short bool, pkg, run string, race, jsonOutput bo cmd.Env = append(os.Environ(), getMacOSDeploymentTarget()) if !jsonOutput { - fmt.Printf("%s %s\n", testHeaderStyle.Render(i18n.T("common.label.test")), i18n.T("common.progress.running", map[string]any{"Task": "tests"})) - fmt.Printf(" %s %s\n", i18n.T("common.label.package"), testDimStyle.Render(pkg)) + fmt.Printf("%s %s\n", testHeaderStyle.Render(i18n.Label("test")), i18n.ProgressSubject("run", "tests")) + fmt.Printf(" %s %s\n", i18n.Label("package"), testDimStyle.Render(pkg)) if run != "" { - fmt.Printf(" %s %s\n", i18n.T("common.label.filter"), testDimStyle.Render(run)) + fmt.Printf(" %s %s\n", i18n.Label("filter"), testDimStyle.Render(run)) } fmt.Println() } @@ -94,7 +94,7 @@ func runTest(verbose, coverage, short bool, pkg, run string, race, jsonOutput bo // JSON output for CI/agents printJSONResults(results, exitCode) if exitCode != 0 { - return errors.New(i18n.T("common.error.failed", map[string]any{"Action": "run tests"})) + return errors.New(i18n.T("i18n.fail.run", "tests")) } return nil } @@ -110,7 +110,7 @@ func runTest(verbose, coverage, short bool, pkg, run string, race, jsonOutput bo if exitCode != 0 { fmt.Printf("\n%s %s\n", testFailStyle.Render(i18n.T("cli.fail")), i18n.T("cmd.test.tests_failed")) - return errors.New(i18n.T("common.error.failed", map[string]any{"Action": "run tests"})) + return errors.New(i18n.T("i18n.fail.run", "tests")) } fmt.Printf("\n%s %s\n", testPassStyle.Render(i18n.T("cli.pass")), i18n.T("common.result.all_passed")) diff --git a/pkg/vm/cmd_container.go b/pkg/vm/cmd_container.go index fd961f9..73188ce 100644 --- a/pkg/vm/cmd_container.go +++ b/pkg/vm/cmd_container.go @@ -70,7 +70,7 @@ func addVMRunCommand(parent *cobra.Command) { func runContainer(image, name string, detach bool, memory, cpus, sshPort int) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.init", "container manager")+": %w", err) } opts := container.RunOptions{ @@ -81,7 +81,7 @@ func runContainer(image, name string, detach bool, memory, cpus, sshPort int) er SSHPort: sshPort, } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.image")), image) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.Label("image")), image) if name != "" { fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.vm.label.name")), name) } @@ -91,11 +91,11 @@ func runContainer(image, name string, detach bool, memory, cpus, sshPort int) er ctx := context.Background() c, err := manager.Run(ctx, image, opts) if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "run container"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.run", "container")+": %w", err) } if detach { - fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.started")), c.ID) + fmt.Printf("%s %s\n", successStyle.Render(i18n.Label("started")), c.ID) fmt.Printf("%s %d\n", dimStyle.Render(i18n.T("cmd.vm.label.pid")), c.PID) fmt.Println() fmt.Println(i18n.T("cmd.vm.hint.view_logs", map[string]interface{}{"ID": c.ID[:8]})) @@ -128,13 +128,13 @@ func addVMPsCommand(parent *cobra.Command) { func listContainers(all bool) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.init", "container manager")+": %w", err) } ctx := context.Background() containers, err := manager.List(ctx) if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "list containers"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.list", "containers")+": %w", err) } // Filter if not showing all @@ -223,7 +223,7 @@ func addVMStopCommand(parent *cobra.Command) { func stopContainer(id string) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.init", "container manager")+": %w", err) } // Support partial ID matching @@ -236,7 +236,7 @@ func stopContainer(id string) error { ctx := context.Background() if err := manager.Stop(ctx, fullID); err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "stop container"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.stop", "container")+": %w", err) } fmt.Printf("%s\n", successStyle.Render(i18n.T("common.status.stopped"))) @@ -292,7 +292,7 @@ func addVMLogsCommand(parent *cobra.Command) { func viewLogs(id string, follow bool) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.init", "container manager")+": %w", err) } fullID, err := resolveContainerID(manager, id) @@ -303,7 +303,7 @@ func viewLogs(id string, follow bool) error { ctx := context.Background() reader, err := manager.Logs(ctx, fullID, follow) if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "get logs"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.get", "logs")+": %w", err) } defer reader.Close() @@ -331,7 +331,7 @@ func addVMExecCommand(parent *cobra.Command) { func execInContainer(id string, cmd []string) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) + return fmt.Errorf(i18n.T("i18n.fail.init", "container manager")+": %w", err) } fullID, err := resolveContainerID(manager, id)