Skip to content

Desktop: /init and /review descriptions are not localized, and the compaction summary template is English-only #57828

Open

Description

@xvcezrqpbxtpzblrt

Description

Two localization gaps are still open in 2.1.2 (desktop). Both are verified against the shipped build (resources/opencode-cli.exe contains the exact strings quoted below). This is a re-file of #51016, which was closed during the V1 triage and cannot be reopened.

The front-end half of the original report is already fixed: the compaction panel now uses the ui.messagePart.compaction.* i18n keys, and the old V1 headings are gone from the UI. What remains is narrower and lives in the core.

1. /init and /review descriptions are English in every locale

packages/core/src/plugin/command.ts:

30:        name: "init",
31:        description: "guided AGENTS.md setup",
43:        name: "review",
44:        description: "review changes [commit|branch|pr], defaults to uncommitted",

There is no t() lookup, and no key to supply one: command.init and command.review do not exist in packages/app/src/runtime/i18n/en.ts or zh.ts. The composer passes the string through untouched (packages/app/src/composer/model.ts:226-232, description: item.description), and the plugin API only accepts a plain string (packages/plugin/src/effect/command.ts:16), so no locale can override it. Every other slash entry resolves through language.t(...) (packages/app/src/session/commands/use-session-commands.tsx:327-374); these two are the only exceptions.

2. The compaction summary headings are English by construction

packages/core/src/session/compaction.ts:107-138 holds the model-facing SUMMARY_TEMPLATE with ## Objective, ## Work State, ## Next Move, ## Relevant Files. buildPrompt (line 148) takes no locale, and the reply is rendered as-is by PacedMarkdown (packages/session-ui/src/message/message-content.tsx:638).

This one cannot be fixed with UI strings alone, because the same template is used to validate the reply:

287:      const headings = SUMMARY_TEMPLATE.split("\n").filter((line) => line.startsWith("##"))
288:      const filled = (text: string) => text.split("\n").some((line) => headings.includes(line.trim()))

A localized heading fails filled() and costs a retry, so the template itself has to become locale-aware.

Suggested fix: (1) add command.init / command.review keys and map the plugin command name to a key in the composer; (2) pass the UI locale into buildPrompt and derive the heading list from the localized template.

Steps to reproduce

  1. OpenCode Desktop 2.1.2, set the UI language to Chinese.
  2. Type / in the composer: /init shows "guided AGENTS.md setup" and /review shows "review changes [commit|branch|pr], defaults to uncommitted" — both in English, while /compact, /undo and /new next to them are Chinese.
  3. Run /compact: the summary body contains ## Objective, ## Work State, ## Next Move, ## Relevant Files.

Expected: both follow the selected UI language. Actual: only these two entries and the summary template stay English.

OpenCode version

2.1.2 (desktop, bundled CLI 2.1.2; tag v2.1.2, commit a517687fde98a7329ada3ae644a01a9fc6c4e99e). Still present on dev at f7577a1.

Operating System

Windows 11 (10.0.26300)

Terminal

Not applicable (desktop app)

Plugins

None.

Screenshot

Not attached — the difference is textual only.

Activity

  1. opencode-agent commented on Oct 21, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I can confirm the /init and /review part on 2.1.2, and it still happens on the latest dev (870ab9d).

    I couldn't run the desktop app or a browser here, so I checked the server and the app code instead. The script below starts opencode serve and asks it for the command list with a Chinese Accept-Language. It returns only these two built-in commands, with their English descriptions and no locale or translation key:

    [{"name":"init","description":"guided AGENTS.md setup"},{"name":"review","description":"review changes [commit|branch|pr], defaults to uncommitted"}]

    The composer (packages/app/src/composer/model.ts) shows that description unchanged, and the app dictionaries have no command.init or command.review keys. The neighbouring entries (e.g. /compact → 压缩会话) are translated. So these two stay English in every locale, as you describe.

    I only checked the compaction headings in the code: SUMMARY_TEMPLATE is English and is also used to check the reply. That part is about the model's output language, which overlaps with #49889, so maintainers may handle it there.

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduces #57828 (part 1): the built-in /init and /review commands are served
    # with hard-coded English descriptions and no i18n key, regardless of locale.
    # Usage: ./repro.sh            -> uses `opencode` from PATH (e.g. @opencode/[email protected])
    #        OC_DEV=/path/to/repo ./repro.sh -> runs the CLI from a source checkout
    set -euo pipefail
    PORT=${PORT:-4599}
    PROJ=$(mktemp -d /tmp/opencode/proj.XXXX)
    cd "$PROJ" && git init -q
    if [ -n "${OC_DEV:-}" ]; then
      OC=(bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts")
    else
      OC=(opencode)
    fi
    "${OC[@]}" --version
    LOG=$(mktemp /tmp/opencode/serve.XXXX)
    "${OC[@]}" serve --hostname 127.0.0.1 --port "$PORT" >"$LOG" 2>&1 &
    SRV=$!
    trap 'kill $SRV 2>/dev/null' EXIT
    for _ in $(seq 60); do grep -q password "$LOG" && break; sleep 1; done
    PASS=$(grep password "$LOG" | awk '{print $3}')
    # commands are registered asynchronously after the location boots; poll
    for _ in $(seq 60); do
      OUT=$(curl -s -u "opencode:$PASS" -H 'accept-language: zh-CN' "http://127.0.0.1:$PORT/api/command?directory=$PROJ")
      echo "$OUT" | grep -q '"init"' && break
      sleep 2
    done
    echo "GET /api/command (Accept-Language: zh-CN):"
    echo "$OUT"
    if [ -n "${OC_DEV:-}" ]; then
      echo "--- i18n keys for init/review in app dictionaries (expect none):"
      grep -n '"command\.init\|"command\.review"' "$OC_DEV"/packages/app/src/runtime/i18n/{en,zh}.ts || echo "(none)"
    fi

    Run it: bash repro.sh

  2. imgusguo commented on Oct 21, 2026

    @imgusguo

    I'd like to work on the /init and /review descriptions. Could you confirm which command-identification approach you prefer?

    Scope

    Route these two descriptions through app i18n in the desktop/web composer, preserving the English wording. Compaction prompts/headings and TUI localization would be separate work.

    Following the app's localization guidance, this first change would add English keys and fallback. Non-English translations would follow language review; those locales would still show English until then.

    Identifying built-in commands

    The command list exposes only name and description; later definitions can replace same-name commands. Matching by name alone could overwrite a user/plugin description.

    A — App-only matching (preferred): Translate only when both name and description match the built-in defaults, comparing against the English dictionary. Preserve other descriptions. This avoids a wire-format change, but depends on the default wording and cannot distinguish a custom command with identical name and description.

    B — Explicit origin metadata: Carry a built-in marker from registration through the command list. This reliably distinguishes overrides, but expands the change to command interfaces, schema, and generated clients.

    Verification

    Extend existing slash-command coverage for default descriptions, same-name/custom overrides, and English fallback. Verify locale switching when reviewed translations are available. Preserve command order and execution behavior.

    Would you accept A, or prefer B? I'd take only the description portion of #57828 and reference the issue without closing the compaction portion.

    AI assistance: I used Codex to inspect the relevant source and draft this proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions