From 6f6ee99008dd30974818207818cee24f5daf3e48 Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 30 Jan 2026 11:44:45 +0000 Subject: [PATCH] refactor(i18n): consolidate 85 keys into reusable templates Replace specific messages with parameterized templates: - 60 "failed to X" errors -> common.error.failed + Action - 10 "Running X" messages -> common.progress.running + Task - 4 "Checking X" messages -> common.progress.checking + Item - 13 "X successfully" messages -> common.success.completed + Action This reduces translation maintenance - translators only need to translate 3 templates instead of 85 individual messages. Co-Authored-By: Claude Opus 4.5 --- cmd/ai/ai_git.go | 18 +++--- cmd/ai/ai_tasks.go | 12 ++-- cmd/ai/ai_updates.go | 8 +-- cmd/build/build_project.go | 6 +- cmd/build/build_pwa.go | 26 ++++----- cmd/ci/ci_changelog.go | 2 +- cmd/ci/ci_init.go | 2 +- cmd/ci/ci_version.go | 2 +- cmd/dev/dev_sync.go | 2 +- cmd/docs/scan.go | 6 +- cmd/doctor/doctor.go | 2 +- cmd/go/go_test_cmd.go | 12 ++-- cmd/php/php_build.go | 12 ++-- cmd/php/php_deploy.go | 10 ++-- cmd/php/php_dev.go | 8 +-- cmd/php/php_packages.go | 6 +- cmd/php/php_quality.go | 20 +++---- cmd/pkg/pkg_install.go | 2 +- cmd/pkg/pkg_manage.go | 6 +- cmd/pkg/pkg_search.go | 2 +- cmd/sdk/sdk.go | 2 +- cmd/setup/setup_registry.go | 2 +- cmd/test/test_runner.go | 2 +- cmd/vm/container.go | 16 +++--- cmd/vm/templates.go | 12 ++-- pkg/i18n/locales/en_GB.json | 107 +++--------------------------------- 26 files changed, 107 insertions(+), 198 deletions(-) diff --git a/cmd/ai/ai_git.go b/cmd/ai/ai_git.go index 61b91e5..aeb72c6 100644 --- a/cmd/ai/ai_git.go +++ b/cmd/ai/ai_git.go @@ -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("cmd.ai.error.get_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get task"}), err) } // Build commit message with optional scope @@ -77,7 +77,7 @@ var taskCommitCmd = &cobra.Command{ // Check for uncommitted changes hasChanges, err := agentic.HasUncommittedChanges(ctx, cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.git_status"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "check git status"}), err) } if !hasChanges { @@ -88,7 +88,7 @@ var taskCommitCmd = &cobra.Command{ // Create commit fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_commit.creating", map[string]interface{}{"ID": taskID})) if err := agentic.AutoCommit(ctx, task, cwd, fullMessage); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.commit"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "commit"}), err) } fmt.Printf("%s %s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_commit.committed"), fullMessage) @@ -97,9 +97,9 @@ var taskCommitCmd = &cobra.Command{ if taskCommitPush { fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_commit.pushing")) if err := agentic.PushChanges(ctx, cwd); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.push"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "push"}), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_commit.pushed")) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Changes pushed"})) } return nil @@ -127,7 +127,7 @@ var taskPRCmd = &cobra.Command{ // Get task details task, err := client.GetTask(ctx, taskID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.get_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get task"}), err) } // Get current directory @@ -139,7 +139,7 @@ var taskPRCmd = &cobra.Command{ // Check current branch branch, err := agentic.GetCurrentBranch(ctx, cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.get_branch"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get current branch"}), err) } if branch == "main" || branch == "master" { @@ -151,7 +151,7 @@ var taskPRCmd = &cobra.Command{ 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("cmd.ai.error.push_branch"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "push branch"}), err) } } @@ -170,7 +170,7 @@ var taskPRCmd = &cobra.Command{ fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("cmd.ai.task_pr.creating")) prURL, err := agentic.CreatePR(ctx, task, cwd, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.create_pr"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create PR"}), err) } fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_pr.created")) diff --git a/cmd/ai/ai_tasks.go b/cmd/ai/ai_tasks.go index d4cfa09..ad93014 100644 --- a/cmd/ai/ai_tasks.go +++ b/cmd/ai/ai_tasks.go @@ -68,7 +68,7 @@ var tasksCmd = &cobra.Command{ tasks, err := client.ListTasks(ctx, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.list_tasks"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list tasks"}), err) } if len(tasks) == 0 { @@ -111,7 +111,7 @@ var taskCmd = &cobra.Command{ Limit: 50, }) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.list_tasks"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.ai.error.get_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.ai.task.context_failed"), err) + fmt.Printf("%s %s: %s\n", errorStyle.Render(">>"), i18n.T("common.error.failed", map[string]any{"Action": "build context"}), err) } else { fmt.Println(taskCtx.FormatContext()) } @@ -163,10 +163,10 @@ var taskCmd = &cobra.Command{ claimedTask, err := client.ClaimTask(ctx, task.ID) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.claim_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "claim task"}), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task.claimed")) + 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)) } diff --git a/cmd/ai/ai_updates.go b/cmd/ai/ai_updates.go index 0a32280..52c634d 100644 --- a/cmd/ai/ai_updates.go +++ b/cmd/ai/ai_updates.go @@ -57,10 +57,10 @@ var taskUpdateCmd = &cobra.Command{ } if err := client.UpdateTask(ctx, taskID, update); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.update_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "update task"}), err) } - fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("cmd.ai.task_update.success", map[string]interface{}{"ID": taskID})) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task updated"})) return nil }, } @@ -90,13 +90,13 @@ var taskCompleteCmd = &cobra.Command{ } if err := client.CompleteTask(ctx, taskID, result); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ai.error.complete_task"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.ai.task_complete.success", map[string]interface{}{"ID": taskID})) + fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task completed"})) } return nil }, diff --git a/cmd/build/build_project.go b/cmd/build/build_project.go index b2a824d..7e5fb88 100644 --- a/cmd/build/build_project.go +++ b/cmd/build/build_project.go @@ -41,7 +41,7 @@ func runProjectBuild(buildType string, ciMode bool, targetsFlag string, outputDi } else { projectType, err = buildpkg.PrimaryType(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.error.detect_type"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "detect project type"}), err) } if projectType == "" { return fmt.Errorf("%s", i18n.T("cmd.build.error.no_project_type", map[string]interface{}{"Dir": projectDir})) @@ -240,7 +240,7 @@ func runProjectBuild(buildType string, ciMode bool, targetsFlag string, outputDi // JSON output for CI output, err := json.MarshalIndent(outputArtifacts, "", " ") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.error.marshal_artifacts"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "marshal artifacts"}), err) } fmt.Println(string(output)) } @@ -267,7 +267,7 @@ func computeAndWriteChecksums(ctx context.Context, projectDir, outputDir string, checksumPath := filepath.Join(outputDir, "CHECKSUMS.txt") if err := buildpkg.WriteChecksumFile(checksummedArtifacts, checksumPath); err != nil { if !ciMode { - fmt.Printf("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.write_checksums"), err) + fmt.Printf("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("common.error.failed", map[string]any{"Action": "write CHECKSUMS.txt"}), err) } return nil, err } diff --git a/cmd/build/build_pwa.go b/cmd/build/build_pwa.go index f25f3d5..b3ca3f4 100644 --- a/cmd/build/build_pwa.go +++ b/cmd/build/build_pwa.go @@ -36,13 +36,13 @@ func runPwaBuild(pwaURL string) error { tempDir, err := os.MkdirTemp("", "core-pwa-build-*") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.create_temp_dir"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create temporary directory"}), err) } // defer os.RemoveAll(tempDir) // Keep temp dir for debugging fmt.Printf("%s %s\n", i18n.T("cmd.build.pwa.downloading_to"), tempDir) if err := downloadPWA(pwaURL, tempDir); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.download_failed"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "download PWA"}), err) } return runBuild(tempDir) @@ -53,13 +53,13 @@ func downloadPWA(baseURL, destDir string) error { // Fetch the main HTML page resp, err := http.Get(baseURL) if err != nil { - return fmt.Errorf("%s %s: %w", i18n.T("cmd.build.pwa.error.fetch_url"), baseURL, err) + return fmt.Errorf("%s %s: %w", i18n.T("common.error.failed", map[string]any{"Action": "fetch URL"}), baseURL, err) } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.read_response"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "read response body"}), err) } // Find the manifest URL from the HTML @@ -68,7 +68,7 @@ func downloadPWA(baseURL, destDir string) error { // If no manifest, it's not a PWA, but we can still try to package it as a simple site. fmt.Printf("%s %s\n", i18n.T("common.label.warning"), i18n.T("cmd.build.pwa.no_manifest")) if err := os.WriteFile(filepath.Join(destDir, "index.html"), body, 0644); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.write_index"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "write index.html"}), err) } return nil } @@ -78,20 +78,20 @@ func downloadPWA(baseURL, destDir string) error { // Fetch and parse the manifest manifest, err := fetchManifest(manifestURL) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.fetch_manifest"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "fetch or parse manifest"}), err) } // Download all assets listed in the manifest assets := collectAssets(manifest, manifestURL) for _, assetURL := range assets { if err := downloadAsset(assetURL, destDir); err != nil { - fmt.Printf("%s %s %s: %v\n", i18n.T("common.label.warning"), i18n.T("cmd.build.pwa.asset_download_failed"), assetURL, err) + fmt.Printf("%s %s %s: %v\n", i18n.T("common.label.warning"), i18n.T("common.error.failed", map[string]any{"Action": "download asset"}), assetURL, err) } } // Also save the root index.html if err := os.WriteFile(filepath.Join(destDir, "index.html"), body, 0644); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.pwa.error.write_index"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "write index.html"}), err) } fmt.Println(i18n.T("cmd.build.pwa.download_complete")) @@ -238,29 +238,29 @@ func runBuild(fromPath string) error { outputExe := appName if err := os.RemoveAll(buildDir); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.from_path.error.clean_build_dir"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "clean build directory"}), err) } // 1. Generate the project from the embedded template fmt.Println(i18n.T("cmd.build.from_path.generating_template")) templateFS, err := debme.FS(guiTemplate, "tmpl/gui") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.from_path.error.anchor_template"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "anchor template filesystem"}), err) } sod := gosod.New(templateFS) if sod == nil { - return fmt.Errorf("%s", i18n.T("cmd.build.from_path.error.create_sod")) + return fmt.Errorf("%s", i18n.T("common.error.failed", map[string]any{"Action": "create new sod instance"})) } templateData := map[string]string{"AppName": appName} if err := sod.Extract(buildDir, templateData); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.from_path.error.extract_template"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "extract template"}), err) } // 2. Copy the user's web app files fmt.Println(i18n.T("cmd.build.from_path.copying_files")) if err := copyDir(fromPath, htmlDir); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.build.from_path.error.copy_files"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "copy application files"}), err) } // 3. Compile the application diff --git a/cmd/ci/ci_changelog.go b/cmd/ci/ci_changelog.go index f7e3512..90e5e5d 100644 --- a/cmd/ci/ci_changelog.go +++ b/cmd/ci/ci_changelog.go @@ -24,7 +24,7 @@ func runChangelog(fromRef, toRef string) error { // Generate changelog changelog, err := release.GenerateWithConfig(projectDir, fromRef, toRef, &cfg.Changelog) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ci.error.generate_changelog"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "generate changelog"}), err) } fmt.Println(changelog) diff --git a/cmd/ci/ci_init.go b/cmd/ci/ci_init.go index aafb7c2..d2dc62c 100644 --- a/cmd/ci/ci_init.go +++ b/cmd/ci/ci_init.go @@ -61,7 +61,7 @@ func runCIReleaseInit() error { // Write config if err := release.WriteConfig(cfg, projectDir); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ci.error.write_config"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "write config"}), err) } fmt.Println() diff --git a/cmd/ci/ci_version.go b/cmd/ci/ci_version.go index 1ed8384..00da9e9 100644 --- a/cmd/ci/ci_version.go +++ b/cmd/ci/ci_version.go @@ -17,7 +17,7 @@ func runCIReleaseVersion() error { version, err := release.DetermineVersion(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.ci.error.determine_version"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "determine version"}), err) } fmt.Printf("%s %s\n", i18n.T("common.label.version"), releaseValueStyle.Render(version)) diff --git a/cmd/dev/dev_sync.go b/cmd/dev/dev_sync.go index 9a9b136..5eec722 100644 --- a/cmd/dev/dev_sync.go +++ b/cmd/dev/dev_sync.go @@ -26,7 +26,7 @@ func addSyncCommand(parent *cobra.Command) { if err := runSync(); err != nil { return fmt.Errorf("%s %w", i18n.T("common.label.error"), err) } - fmt.Println(i18n.T("cmd.dev.sync.success")) + fmt.Println(i18n.T("common.success.completed", map[string]any{"Action": "Public APIs synchronized"})) return nil }, } diff --git a/cmd/docs/scan.go b/cmd/docs/scan.go index 5665ec7..f590474 100644 --- a/cmd/docs/scan.go +++ b/cmd/docs/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("cmd.docs.error.load_registry"), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.docs.error.load_registry"), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.docs.error.scan_directory"), err) + return nil, "", fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "scan directory"}), err) } basePath = cwd } diff --git a/cmd/doctor/doctor.go b/cmd/doctor/doctor.go index a042b2b..c7c646d 100644 --- a/cmd/doctor/doctor.go +++ b/cmd/doctor/doctor.go @@ -33,7 +33,7 @@ func init() { } func runDoctor(verbose bool) error { - fmt.Println(i18n.T("cmd.doctor.checking")) + fmt.Println(i18n.T("common.progress.checking", map[string]any{"Item": "development environment"})) fmt.Println() var passed, failed, optional int diff --git a/cmd/go/go_test_cmd.go b/cmd/go/go_test_cmd.go index ab6cb9e..72f0e3e 100644 --- a/cmd/go/go_test_cmd.go +++ b/cmd/go/go_test_cmd.go @@ -73,7 +73,7 @@ func runGoTest(coverage bool, pkg, run string, short, race, jsonOut, verbose boo args = append(args, pkg) if !jsonOut { - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.test")), i18n.T("common.result.running_tests")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.test")), i18n.T("common.progress.running", map[string]any{"Task": "tests"})) fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("common.label.package")), pkg) fmt.Println() } @@ -176,7 +176,7 @@ func addGoCovCommand(parent *cobra.Command) { // Auto-discover packages with tests pkgs, err := findTestPackages(".") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.go.cov.error.discover"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "discover test packages"}), err) } if len(pkgs) == 0 { return fmt.Errorf(i18n.T("cmd.go.cov.error.no_packages")) @@ -187,13 +187,13 @@ func addGoCovCommand(parent *cobra.Command) { // Create temp file for coverage data covFile, err := os.CreateTemp("", "coverage-*.out") if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.go.cov.error.create_file"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "create coverage file"}), err) } covPath := covFile.Name() covFile.Close() defer os.Remove(covPath) - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.coverage")), i18n.T("cmd.go.cov.running")) + fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.coverage")), i18n.T("common.progress.running", map[string]any{"Task": "tests with coverage"})) // Truncate package list if too long for display displayPkg := pkg if len(displayPkg) > 60 { @@ -221,7 +221,7 @@ func addGoCovCommand(parent *cobra.Command) { if testErr != nil { return testErr } - return fmt.Errorf("%s: %w", i18n.T("cmd.go.cov.error.get_coverage"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get coverage"}), err) } // Parse total coverage from last line @@ -248,7 +248,7 @@ func addGoCovCommand(parent *cobra.Command) { htmlPath := "coverage.html" htmlCmd := exec.Command("go", "tool", "cover", "-html="+covPath, "-o="+htmlPath) if err := htmlCmd.Run(); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.go.cov.error.generate_html"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "generate HTML"}), err) } fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("cmd.go.cov.html_label")), htmlPath) diff --git a/cmd/php/php_build.go b/cmd/php/php_build.go index 4a2912d..d46e322 100644 --- a/cmd/php/php_build.go +++ b/cmd/php/php_build.go @@ -92,7 +92,7 @@ func runPHPBuildDocker(ctx context.Context, projectDir string, opts dockerBuildO // Show detected configuration config, err := phppkg.DetectDockerfileConfig(projectDir) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.detect_config"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "detect project configuration"}), err) } fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.build.php_version")), config.PHPVersion) @@ -138,7 +138,7 @@ func runPHPBuildDocker(ctx context.Context, projectDir string, opts dockerBuildO return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.docker_success")) + 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("%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) @@ -176,7 +176,7 @@ func runPHPBuildLinuxKit(ctx context.Context, projectDir string, opts linuxKitBu return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err) } - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.linuxkit_success")) + 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"})) return nil } @@ -224,7 +224,7 @@ func addPHPServeCommand(parent *cobra.Command) { Output: os.Stdout, } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.serve.running")) + 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 { if serveTag == "" { return "latest" @@ -246,7 +246,7 @@ func addPHPServeCommand(parent *cobra.Command) { fmt.Println() if err := phppkg.ServeProduction(ctx, opts); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.start_container"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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 := phppkg.Shell(ctx, args[0]); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.open_shell"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "open shell"}), err) } return nil diff --git a/cmd/php/php_deploy.go b/cmd/php/php_deploy.go index 1f0e40e..32404d8 100644 --- a/cmd/php/php_deploy.go +++ b/cmd/php/php_deploy.go @@ -75,7 +75,7 @@ func addPHPDeployCommand(parent *cobra.Command) { if deployWait { if phppkg.IsDeploymentSuccessful(status.Status) { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.deploy.success")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.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})) } @@ -115,7 +115,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) { env = phppkg.EnvStaging } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.deploy")), i18n.T("cmd.php.deploy_status.checking", map[string]interface{}{"Environment": env})) + 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"})) ctx := context.Background() @@ -127,7 +127,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) { status, err := phppkg.DeployStatus(ctx, opts) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.status_failed"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get status"}), err) } printDeploymentStatus(status) @@ -184,7 +184,7 @@ func addPHPDeployRollbackCommand(parent *cobra.Command) { if rollbackWait { if phppkg.IsDeploymentSuccessful(status.Status) { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.deploy_rollback.success")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.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})) } @@ -235,7 +235,7 @@ func addPHPDeployListCommand(parent *cobra.Command) { deployments, err := phppkg.ListDeployments(ctx, cwd, env, limit) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.list_deployments"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list deployments"}), err) } if len(deployments) == 0 { diff --git a/cmd/php/php_dev.go b/cmd/php/php_dev.go index cae5207..ca88f98 100644 --- a/cmd/php/php_dev.go +++ b/cmd/php/php_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("cmd.php.error.start_services"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "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("cmd.php.dev.logs_failed", map[string]interface{}{"Error": err})) + fmt.Printf("%s %s\n", errorStyle.Render(i18n.T("common.label.warning")), i18n.T("common.error.failed", map[string]any{"Action": "get logs"})) } else { defer logsReader.Close() @@ -270,7 +270,7 @@ func runPHPStop() error { // This is a simplified version - in practice you'd want to track PIDs server := phppkg.NewDevServer(phppkg.Options{Dir: cwd}) if err := server.Stop(); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.stop_services"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "stop services"}), err) } fmt.Printf("%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.dev.all_stopped")) @@ -394,7 +394,7 @@ func runPHPSSL(domain string) error { // Setup SSL if err := phppkg.SetupSSL(domain, phppkg.SSLOptions{}); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.ssl_setup"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "setup SSL"}), err) } certFile, keyFile, _ := phppkg.CertPaths(domain, phppkg.SSLOptions{}) diff --git a/cmd/php/php_packages.go b/cmd/php/php_packages.go index 4a45414..32fd60b 100644 --- a/cmd/php/php_packages.go +++ b/cmd/php/php_packages.go @@ -38,7 +38,7 @@ func addPHPPackagesLinkCommand(parent *cobra.Command) { fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.link.linking")) if err := phppkg.LinkPackages(cwd, args); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.link_packages"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "link packages"}), err) } fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.packages.link.done")) @@ -64,7 +64,7 @@ func addPHPPackagesUnlinkCommand(parent *cobra.Command) { fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.unlink.unlinking")) if err := phppkg.UnlinkPackages(cwd, args); err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.unlink_packages"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "unlink packages"}), err) } fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.packages.unlink.done")) @@ -113,7 +113,7 @@ func addPHPPackagesListCommand(parent *cobra.Command) { packages, err := phppkg.ListLinkedPackages(cwd) if err != nil { - return fmt.Errorf("%s: %w", i18n.T("cmd.php.error.list_packages"), err) + return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "list packages"}), err) } if len(packages) == 0 { diff --git a/cmd/php/php_quality.go b/cmd/php/php_quality.go index d55edc8..bd70390 100644 --- a/cmd/php/php_quality.go +++ b/cmd/php/php_quality.go @@ -37,9 +37,7 @@ func addPHPTestCommand(parent *cobra.Command) { return fmt.Errorf(i18n.T("cmd.php.error.not_php")) } - // Detect test runner - runner := phppkg.DetectTestRunner(cwd) - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.test.running", map[string]interface{}{"Runner": runner})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("common.progress.running", map[string]any{"Task": "tests"})) ctx := context.Background() @@ -101,7 +99,7 @@ func addPHPFmtCommand(parent *cobra.Command) { if fmtFix { msg = i18n.T("cmd.php.fmt.formatting", map[string]interface{}{"Formatter": formatter}) } else { - msg = i18n.T("cmd.php.fmt.checking", map[string]interface{}{"Formatter": formatter}) + msg = i18n.T("common.progress.checking", map[string]any{"Item": "code style"}) } fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), msg) @@ -127,7 +125,7 @@ func addPHPFmtCommand(parent *cobra.Command) { } if fmtFix { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.fmt.success")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.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")) } @@ -163,12 +161,12 @@ func addPHPAnalyseCommand(parent *cobra.Command) { } // Detect analyser - analyser, found := phppkg.DetectAnalyser(cwd) + _, found := phppkg.DetectAnalyser(cwd) if !found { return fmt.Errorf(i18n.T("cmd.php.analyse.no_analyser")) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.analyse.running", map[string]interface{}{"Analyser": 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"})) ctx := context.Background() @@ -383,7 +381,7 @@ func addPHPSecurityCommand(parent *cobra.Command) { return fmt.Errorf(i18n.T("cmd.php.error.not_php")) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.security")), i18n.T("cmd.php.security.running")) + 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"})) ctx := context.Background() @@ -495,7 +493,7 @@ func addPHPQACommand(parent *cobra.Command) { for i, s := range stages { stageNames[i] = string(s) } - fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.qa")), i18n.T("cmd.php.qa.running", map[string]interface{}{"Stages": strings.Join(stageNames, " -> ")})) + fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.qa")), i18n.T("common.progress.running", map[string]any{"Task": "QA pipeline"})) ctx := context.Background() var allPassed = true @@ -725,7 +723,7 @@ func addPHPRectorCommand(parent *cobra.Command) { } if rectorFix { - fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.rector.refactored")) + fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.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")) } @@ -770,7 +768,7 @@ func addPHPInfectionCommand(parent *cobra.Command) { return fmt.Errorf(i18n.T("cmd.php.error.infection_not_installed")) } - fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.php.label.infection")), i18n.T("cmd.php.infection.running")) + 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\n", dimStyle.Render(i18n.T("cmd.php.label.info")), i18n.T("cmd.php.infection.note")) ctx := context.Background() diff --git a/cmd/pkg/pkg_install.go b/cmd/pkg/pkg_install.go index 05527d1..b8cdcea 100644 --- a/cmd/pkg/pkg_install.go +++ b/cmd/pkg/pkg_install.go @@ -78,7 +78,7 @@ func runPkgInstall(repoArg, targetDir string, addToRegistry bool) error { } if err := os.MkdirAll(targetDir, 0755); err != nil { - return fmt.Errorf(i18n.T("cmd.pkg.error.create_directory"), err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "create directory"}), err) } fmt.Printf("%s %s/%s\n", dimStyle.Render(i18n.T("cmd.pkg.install.installing_label")), org, repoName) diff --git a/cmd/pkg/pkg_manage.go b/cmd/pkg/pkg_manage.go index 067a4c1..d07d9d8 100644 --- a/cmd/pkg/pkg_manage.go +++ b/cmd/pkg/pkg_manage.go @@ -34,7 +34,7 @@ func runPkgList() error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf(i18n.T("cmd.pkg.error.load_registry"), err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) } basePath := reg.BasePath @@ -120,7 +120,7 @@ func runPkgUpdate(packages []string, all bool) error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf(i18n.T("cmd.pkg.error.load_registry"), err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) } basePath := reg.BasePath @@ -200,7 +200,7 @@ func runPkgOutdated() error { reg, err := repos.LoadRegistry(regPath) if err != nil { - return fmt.Errorf(i18n.T("cmd.pkg.error.load_registry"), err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "load registry"}), err) } basePath := reg.BasePath diff --git a/cmd/pkg/pkg_search.go b/cmd/pkg/pkg_search.go index 368de22..cece266 100644 --- a/cmd/pkg/pkg_search.go +++ b/cmd/pkg/pkg_search.go @@ -118,7 +118,7 @@ func runPkgSearch(org, pattern, repoType string, limit int, refresh bool) error } if err := json.Unmarshal(output, &ghRepos); err != nil { - return fmt.Errorf(i18n.T("cmd.pkg.error.parse_results"), err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "parse results"}), err) } if c != nil { diff --git a/cmd/sdk/sdk.go b/cmd/sdk/sdk.go index d8d622a..df3d004 100644 --- a/cmd/sdk/sdk.go +++ b/cmd/sdk/sdk.go @@ -80,7 +80,7 @@ func runSDKDiff(basePath, specPath string) error { return fmt.Errorf(i18n.T("cmd.sdk.diff.error.base_required")) } - fmt.Printf("%s %s\n", sdkHeaderStyle.Render(i18n.T("cmd.sdk.diff.label")), i18n.T("cmd.sdk.diff.checking")) + 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", i18n.T("cmd.sdk.diff.base_label"), sdkDimStyle.Render(basePath)) fmt.Printf(" %s %s\n", i18n.T("common.label.current"), sdkDimStyle.Render(specPath)) fmt.Println() diff --git a/cmd/setup/setup_registry.go b/cmd/setup/setup_registry.go index 6cad054..cec4951 100644 --- a/cmd/setup/setup_registry.go +++ b/cmd/setup/setup_registry.go @@ -200,7 +200,7 @@ 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("cmd.setup.running_build")) + fmt.Printf("%s %s\n", dimStyle.Render(">>"), i18n.T("common.progress.running", map[string]any{"Task": "build"})) buildCmd := exec.Command("core", "build") buildCmd.Dir = basePath buildCmd.Stdout = os.Stdout diff --git a/cmd/test/test_runner.go b/cmd/test/test_runner.go index ad235f6..813380a 100644 --- a/cmd/test/test_runner.go +++ b/cmd/test/test_runner.go @@ -54,7 +54,7 @@ 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.result.running_tests")) + 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)) if run != "" { fmt.Printf(" %s %s\n", i18n.T("common.label.filter"), testDimStyle.Render(run)) diff --git a/cmd/vm/container.go b/cmd/vm/container.go index a4c731f..5d0907d 100644 --- a/cmd/vm/container.go +++ b/cmd/vm/container.go @@ -69,7 +69,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("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } opts := container.RunOptions{ @@ -90,7 +90,7 @@ 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("cmd.vm.error.run_container")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "run container"})+": %w", err) } if detach { @@ -127,13 +127,13 @@ func addVMPsCommand(parent *cobra.Command) { func listContainers(all bool) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } ctx := context.Background() containers, err := manager.List(ctx) if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.list_containers")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "list containers"})+": %w", err) } // Filter if not showing all @@ -222,7 +222,7 @@ func addVMStopCommand(parent *cobra.Command) { func stopContainer(id string) error { manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } // Support partial ID matching @@ -235,7 +235,7 @@ func stopContainer(id string) error { ctx := context.Background() if err := manager.Stop(ctx, fullID); err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.stop_container")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "stop container"})+": %w", err) } fmt.Printf("%s\n", successStyle.Render(i18n.T("common.status.stopped"))) @@ -291,7 +291,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("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } fullID, err := resolveContainerID(manager, id) @@ -330,7 +330,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("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } fullID, err := resolveContainerID(manager, id) diff --git a/cmd/vm/templates.go b/cmd/vm/templates.go index b96a680..700008d 100644 --- a/cmd/vm/templates.go +++ b/cmd/vm/templates.go @@ -149,20 +149,20 @@ func RunFromTemplate(templateName string, vars map[string]string, runOpts contai // Apply template with variables content, err := container.ApplyTemplate(templateName, vars) if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.apply_template")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "apply template"})+": %w", err) } // Create a temporary directory for the build tmpDir, err := os.MkdirTemp("", "core-linuxkit-*") if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.create_temp")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "create temp directory"})+": %w", err) } defer os.RemoveAll(tmpDir) // Write the YAML file yamlPath := filepath.Join(tmpDir, templateName+".yml") if err := os.WriteFile(yamlPath, []byte(content), 0644); err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.write_template")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "write template"})+": %w", err) } fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.template")), repoNameStyle.Render(templateName)) @@ -171,7 +171,7 @@ func RunFromTemplate(templateName string, vars map[string]string, runOpts contai // Build the image using linuxkit outputPath := filepath.Join(tmpDir, templateName) if err := buildLinuxKitImage(yamlPath, outputPath); err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.build_image")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "build image"})+": %w", err) } // Find the built image (linuxkit creates .iso or other format) @@ -186,7 +186,7 @@ func RunFromTemplate(templateName string, vars map[string]string, runOpts contai // Run the image manager, err := container.NewLinuxKitManager() if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.init_manager")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "initialize container manager"})+": %w", err) } fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("cmd.vm.label.hypervisor")), manager.Hypervisor().Name()) @@ -195,7 +195,7 @@ func RunFromTemplate(templateName string, vars map[string]string, runOpts contai ctx := context.Background() c, err := manager.Run(ctx, imagePath, runOpts) if err != nil { - return fmt.Errorf(i18n.T("cmd.vm.error.run_container")+": %w", err) + return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "run container"})+": %w", err) } if runOpts.Detach { diff --git a/pkg/i18n/locales/en_GB.json b/pkg/i18n/locales/en_GB.json index 33ba669..f321311 100644 --- a/pkg/i18n/locales/en_GB.json +++ b/pkg/i18n/locales/en_GB.json @@ -76,7 +76,6 @@ "result": { "all_passed": "All tests passed", "no_issues": "No issues found", - "running_tests": "Running tests", "run_with_coverage": "Run tests with coverage" }, "hint": { @@ -154,19 +153,6 @@ }, "short": "Claude Code integration" }, - "error": { - "claim_task": "failed to claim task", - "commit": "failed to commit", - "complete_task": "failed to complete task", - "create_pr": "failed to create PR", - "get_branch": "failed to get current branch", - "get_task": "failed to get task", - "git_status": "failed to check git status", - "list_tasks": "failed to list tasks", - "push": "failed to push", - "push_branch": "failed to push branch", - "update_task": "failed to update task" - }, "label": { "blocked_by": "Blocked by:", "claimed_by": "Claimed by:", @@ -193,9 +179,7 @@ "pending": "pending" }, "task": { - "claimed": "Task claimed successfully!", "claiming": "Claiming task...", - "context_failed": "Failed to build context", "flag": { "auto": "Auto-select highest priority pending task", "claim": "Claim the task after showing details", @@ -217,7 +201,6 @@ "long": "Creates a git commit with a task reference and co-author attribution.\n\nCommit message format:\n feat(scope): description\n\n Task: #123\n Co-Authored-By: Claude \n\nExamples:\n core ai task:commit abc123 --message 'add user authentication'\n core ai task:commit abc123 -m 'fix login bug' --scope auth\n core ai task:commit abc123 -m 'update docs' --push", "message_required": "commit message required (--message or -m)", "no_changes": "No uncommitted changes to commit.", - "pushed": "Changes pushed successfully", "pushing": "Pushing changes...", "short": "Auto-commit changes with task reference" }, @@ -229,8 +212,7 @@ "output": "Summary of the completed work" }, "long": "Marks a task as completed with optional output and artifacts.\n\nExamples:\n core ai task:complete abc123 --output 'Feature implemented'\n core ai task:complete abc123 --failed --error 'Build failed'", - "short": "Mark a task as completed", - "success": "Task {{.ID}} completed successfully" + "short": "Mark a task as completed" }, "task_pr": { "branch_error": "cannot create PR from {{.Branch}} branch; create a feature branch first", @@ -254,8 +236,7 @@ }, "flag_required": "at least one of --status, --progress, or --notes required", "long": "Updates a task's status, progress, or adds notes.\n\nExamples:\n core ai task:update abc123 --status in_progress\n core ai task:update abc123 --progress 50 --notes 'Halfway done'", - "short": "Update task status or progress", - "success": "Task {{.ID}} updated successfully" + "short": "Update task status or progress" }, "tasks": { "flag": { @@ -280,18 +261,15 @@ "error": { "archive_failed": "archive failed", "checksum_failed": "checksum failed", - "detect_type": "failed to detect project type", "gpg_signing_failed": "GPG signing failed", "invalid_target": "invalid target format \"{{.Target}}\", expected OS/arch (e.g., linux/amd64)", - "marshal_artifacts": "failed to marshal artifacts", "no_project_type": "no supported project type detected in {{.Dir}}\nSupported types: go (go.mod), wails (wails.json), node (package.json), php (composer.json)", "no_targets": "no valid targets specified", "node_not_implemented": "Node.js builder not yet implemented", "notarization_failed": "notarization failed", "php_not_implemented": "PHP builder not yet implemented", "signing_failed": "signing failed", - "unsupported_type": "unsupported project type", - "write_checksums": "failed to write CHECKSUMS.txt" + "unsupported_type": "unsupported project type" }, "flag": { "archive": "Create archives (tar.gz for linux/darwin, zip for windows)", @@ -311,11 +289,6 @@ "compiling": "Compiling application...", "copying_files": "Copying application files...", "error": { - "anchor_template": "failed to anchor template filesystem", - "clean_build_dir": "failed to clean build directory", - "copy_files": "failed to copy application files", - "create_sod": "failed to create new sod instance", - "extract_template": "failed to extract template", "go_build": "go build failed", "go_mod_tidy": "go mod tidy failed", "invalid_path": "invalid path specified", @@ -342,17 +315,10 @@ }, "long": "Builds the current project with automatic type detection.\nSupports Go, Wails, Docker, LinuxKit, and Taskfile projects.\nConfiguration can be provided via .core/build.yaml or command-line flags.\n\nExamples:\n core build # Auto-detect and build\n core build --type docker # Build Docker image\n core build --type linuxkit # Build LinuxKit image\n core build --type linuxkit --config linuxkit.yml --format qcow2-bios", "pwa": { - "asset_download_failed": "failed to download asset", "download_complete": "PWA download complete.", "downloading_to": "Downloading PWA to temporary directory:", "error": { - "create_temp_dir": "failed to create temporary directory", - "download_failed": "failed to download PWA", - "fetch_manifest": "failed to fetch or parse manifest", - "fetch_url": "failed to fetch URL", - "no_manifest_tag": "no tag found", - "read_response": "failed to read response body", - "write_index": "failed to write index.html" + "no_manifest_tag": "no tag found" }, "flag": { "url": "The URL of the PWA to build" @@ -393,10 +359,7 @@ }, "dry_run_hint": "(dry-run) use --we-are-go-for-launch to publish", "error": { - "determine_version": "failed to determine version", - "generate_changelog": "failed to generate changelog", - "no_publishers": "no publishers configured in .core/release.yaml", - "write_config": "failed to write config" + "no_publishers": "no publishers configured in .core/release.yaml" }, "flag": { "draft": "Create release as a draft", @@ -456,8 +419,7 @@ "all": "Commit all dirty repos without prompting" }, "long": "Uses Claude to create commits for dirty repos.\nShows uncommitted changes and invokes Claude to generate commit messages.", - "short": "Claude-assisted commits across repos", - "success": "Committed successfully" + "short": "Claude-assisted commits across repos" }, "committed": "committed", "committing": "Committing", @@ -531,7 +493,6 @@ "nothing": "Nothing to push", "pull_and_retry": "Pull changes and retry push?", "short": "Push commits across all repos", - "success": "Pushed successfully", "uncommitted_changes_commit": "You have uncommitted changes. Commit with Claude first?" }, "repos_with_changes": "{{.Count}} repo(s) with uncommitted changes:", @@ -563,8 +524,7 @@ }, "sync": { "long": "This command scans the 'pkg' directory for services and ensures that the\ntop-level public API for each service is in sync with its internal implementation.\nIt automatically generates the necessary Go files with type aliases.", - "short": "Synchronizes public service APIs with internal implementations", - "success": "Public APIs synchronized successfully." + "short": "Synchronizes public service APIs with internal implementations" }, "untracked": "{{.Count}} untracked", "vm": { @@ -676,10 +636,6 @@ } }, "docs": { - "error": { - "load_registry": "failed to load registry", - "scan_directory": "failed to scan directory" - }, "list": { "coverage_summary": "{{.WithDocs}} with docs, {{.WithoutDocs}} without", "header": { @@ -745,7 +701,6 @@ "name": "pnpm" } }, - "checking": "Checking development environment...", "cli_auth": "CLI authenticated", "cli_auth_missing": "CLI authentication - run: gh auth login", "github": "GitHub Access:", @@ -782,10 +737,6 @@ "below_threshold": "FAIL Coverage {{.Actual}}% is below threshold {{.Threshold}}%", "error": { "below_threshold": "coverage below threshold", - "create_file": "failed to create coverage file", - "discover": "failed to discover test packages", - "generate_html": "failed to generate HTML", - "get_coverage": "failed to get coverage", "no_packages": "no test packages found" }, "flag": { @@ -796,7 +747,6 @@ "html_label": "HTML:", "long": "Run tests and generate coverage report.\n\nExamples:\n core go cov # Run with coverage summary\n core go cov --html # Generate HTML report\n core go cov --open # Generate and open HTML report\n core go cov --threshold 80 # Fail if coverage < 80%", "open_manually": "(open manually)", - "running": "Running tests with coverage", "short": "Run tests with coverage report" }, "fmt": { @@ -883,7 +833,6 @@ }, "long": "Run PHPStan or Larastan static analysis.\n\nAuto-detects Larastan if installed, otherwise uses PHPStan.", "no_analyser": "no static analyser found (install PHPStan: composer require phpstan/phpstan --dev)", - "running": "Running static analysis with {{.Analyser}}", "short": "Run PHPStan static analysis" }, "audit": { @@ -904,7 +853,6 @@ "building_docker": "Building Docker image...", "building_linuxkit": "Building LinuxKit image...", "docker_run_with": "Run with:", - "docker_success": "Docker image built successfully", "extensions": "Extensions:", "flag": { "dockerfile": "Path to custom Dockerfile", @@ -919,7 +867,6 @@ "format": "Format:", "frontend": "Frontend:", "laravel": "Laravel:", - "linuxkit_success": "LinuxKit image built successfully", "long": "Build a production-ready container image for the PHP project.\n\nBy default, builds a Docker image using FrankenPHP.\nUse --type linuxkit to build a LinuxKit VM image instead.", "octane": "Octane:", "php_version": "PHP Version:", @@ -935,7 +882,6 @@ }, "long": "Deploy the PHP application to Coolify.\n\nRequires configuration in .env:\n COOLIFY_URL=https://coolify.example.com\n COOLIFY_TOKEN=your-api-token\n COOLIFY_APP_ID=production-app-id\n COOLIFY_STAGING_APP_ID=staging-app-id (optional)", "short": "Deploy to Coolify", - "success": "Deployment completed successfully", "triggered": "Deployment triggered. Use 'core php deploy:status' to check progress.", "warning_status": "Deployment ended with status: {{.Status}}" }, @@ -958,12 +904,10 @@ "long": "Rollback to a previous deployment.\n\nIf no deployment ID is specified, rolls back to the most recent\nsuccessful deployment.", "rolling_back": "Rolling back {{.Environment}}...", "short": "Rollback to previous deployment", - "success": "Rollback completed successfully", "triggered": "Rollback triggered. Use 'core php deploy:status' to check progress.", "warning_status": "Rollback ended with status: {{.Status}}" }, "deploy_status": { - "checking": "Checking {{.Environment}} deployment status...", "flag": { "id": "Specific deployment ID", "staging": "Check staging environment" @@ -983,7 +927,6 @@ "no_vite": "Skip Vite dev server", "port": "FrankenPHP port (default: 8000)" }, - "logs_failed": "Failed to get logs: {{.Error}}", "long": "Starts all detected Laravel services.\n\nAuto-detects:\n - Vite (vite.config.js/ts)\n - Horizon (config/horizon.php)\n - Reverb (config/reverb.php)\n - Redis (from .env)", "press_ctrl_c": "Press Ctrl+C to stop all services", "services_started": "Services started:", @@ -997,36 +940,24 @@ "audit_failed": "audit failed", "critical_high_issues": "critical or high severity issues found", "deploy_failed": "deployment failed", - "detect_config": "failed to detect project configuration", "fmt_failed": "formatting failed", "fmt_issues": "formatting issues found", "infection_failed": "mutation testing failed", "infection_not_installed": "infection not installed", - "link_packages": "failed to link packages", - "list_deployments": "failed to list deployments", - "list_packages": "failed to list packages", "mkcert_not_installed": "mkcert not installed", "not_laravel": "not a Laravel project (missing artisan or laravel/framework)", "not_laravel_short": "not a Laravel project", "not_php": "not a PHP project (missing composer.json)", - "open_shell": "failed to open shell", "psalm_issues": "psalm found issues", "psalm_not_installed": "psalm not installed", "rector_failed": "rector failed", "rector_not_installed": "rector not installed", "rollback_failed": "rollback failed", "security_failed": "security check failed", - "ssl_setup": "failed to setup SSL", - "start_container": "failed to start container", - "start_services": "failed to start services", - "status_failed": "failed to get status", - "stop_services": "failed to stop services", - "unlink_packages": "failed to unlink packages", "update_packages": "composer update failed", "vulns_found": "vulnerabilities found" }, "fmt": { - "checking": "Checking code with {{.Formatter}}", "flag": { "fix": "Auto-fix formatting issues" }, @@ -1034,8 +965,7 @@ "long": "Format PHP code using Laravel Pint.", "no_formatter": "no formatter found (install Laravel Pint: composer require laravel/pint --dev)", "no_issues": "No formatting issues found", - "short": "Format PHP code with Laravel Pint", - "success": "Code formatted successfully" + "short": "Format PHP code with Laravel Pint" }, "infection": { "complete": "Mutation testing complete", @@ -1050,7 +980,6 @@ "long": "Run Infection mutation testing to measure test suite quality.\n\nMutation testing modifies your code and checks if tests catch\nthe changes. High mutation score = high quality tests.\n\nWarning: This can be slow on large codebases.", "not_found": "Infection not found", "note": "This may take a while...", - "running": "Running mutation testing", "short": "Mutation testing for test quality" }, "label": { @@ -1148,7 +1077,6 @@ "no_checks": "No checks available", "passed": "passed", "pipeline_failed": "QA pipeline failed", - "running": "Running QA pipeline ({{.Stages}})", "short": "Run full QA pipeline", "some_failed": "Some checks failed ({{.Passed}}/{{.Total}} passed)", "stage_prefix": "═══ ", @@ -1167,7 +1095,6 @@ "long": "Run Rector for automated code improvements and PHP upgrades.\n\nRector can automatically upgrade PHP syntax, improve code quality,\nand apply framework-specific refactorings.", "no_changes": "No changes needed", "not_found": "Rector not found", - "refactored": "Code refactored successfully", "refactoring": "Refactoring code with Rector", "setup": "./vendor/bin/rector init", "short": "Automated code refactoring" @@ -1185,7 +1112,6 @@ "low": "Low:", "medium": "Medium:", "passed": "Passed:", - "running": "Running security checks", "short": "Security vulnerability scanning", "summary": "Security scan complete" }, @@ -1201,7 +1127,6 @@ "long": "Run a production PHP container.\n\nThis starts the built Docker image in production mode.", "name_required": "--name is required: specify the Docker image name", "ports": "Ports:", - "running": "Running production container...", "short": "Run production container", "stopped": "Container stopped" }, @@ -1252,20 +1177,16 @@ "parallel": "Run tests in parallel" }, "long": "Run PHP tests using PHPUnit or Pest.\n\nAuto-detects Pest if tests/Pest.php exists, otherwise uses PHPUnit.", - "running": "Running tests with {{.Runner}}", "short": "Run PHP tests (PHPUnit/Pest)" } }, "pkg": { "error": { "auth_failed": "authentication failed - try: unset GH_TOKEN && gh auth login", - "create_directory": "failed to create directory: %w", "gh_not_authenticated": "gh CLI not authenticated. Run: gh auth login", "invalid_repo_format": "invalid repo format: use org/repo (e.g., host-uk/core-php)", - "load_registry": "failed to load registry: %w", "no_repos_yaml": "no repos.yaml found", "no_repos_yaml_workspace": "no repos.yaml found - run from workspace directory", - "parse_results": "failed to parse results: %w", "repo_required": "repository is required (e.g., core pkg install host-uk/core-php)", "search_failed": "search failed: %s", "specify_package": "specify package name or use --all" @@ -1337,7 +1258,6 @@ "diff": { "base_label": "Base:", "breaking": "Breaking:", - "checking": "Checking for breaking changes", "error": { "base_required": "--base is required (version tag or file path)" }, @@ -1391,7 +1311,6 @@ "setting_up": "Setting up repository", "would_create": "Would create" }, - "running_build": "Running build...", "short": "Bootstrap workspace or clone packages from registry", "to_clone": "{{.Count}} to clone", "wizard": { @@ -1434,21 +1353,13 @@ }, "vm": { "error": { - "apply_template": "failed to apply template", - "build_image": "failed to build image", - "create_temp": "failed to create temp directory", "id_and_cmd_required": "container ID and command are required", "id_required": "container ID is required", - "init_manager": "failed to initialize container manager", "linuxkit_not_found": "linuxkit not found. Install with: brew install linuxkit (macOS) or see https://github.com/linuxkit/linuxkit", - "list_containers": "failed to list containers", "multiple_match": "multiple containers match '{{.ID}}', be more specific", "no_image_found": "no image found after build", "no_match": "no container found matching: {{.ID}}", - "run_container": "failed to run container", - "stop_container": "failed to stop container", - "template_required": "template name is required", - "write_template": "failed to write template" + "template_required": "template name is required" }, "exec": { "long": "Execute a command inside a running VM via SSH.\n\nExamples:\n core vm exec abc12345 ls -la\n core vm exec abc1 /bin/sh",