Skip to content

feat(control): the control plane answers with a coded message, not a sentence - #55

Merged
fylorn merged 1 commit into
mainfrom
i18n/control
Sep 20, 2026
Merged

fylorn merged 1 commit into
mainfrom
i18n/control

Conversation

@fylorn

@fylorn fylorn commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

An HTTP error from the control plane was a plain-text body, so the desktop app
could only paste it on screen. In a window that ships in two languages, that
sentence is unreadable to half the people who see it.

pub(crate) type Fail = (StatusCode, Json<Msg>);

The body carries a code, the arguments that fill the sentence, and the English
text. The app looks the code up in its own dictionary and falls back to the text
for one it does not know.

About 250 strings across the crate are English, and the error paths carry a code
— control.upstream_not_found, control.default_key_delete,
control.callback_ports_busy, and so on.

Three helpers keep the common cases short

  • internal(e) — a database or serialization failure the app can only report.
    One code, control.internal, with the original sentence in detail.
  • no_such_upstream(name) — the lookup eight handlers were repeating.
  • checked_name(raw, kind) and slug(kind, v) now take the English name of
    the resource kind
    (upstream, proxy, price sheet, gateway key…) and
    put it in args, so the app can pick its own word for it.

Two surfaces beyond the envelope

  • The diagnostics bundle is English Markdown. It is a document a person
    reads before pasting it into an issue, and issues in this repository are in
    English.
  • The ChatGPT sign-in callback pages are English, and the page that carries
    them stopped claiming lang="zh-CN" while showing English.

crates/tw-control/src no longer contains a Chinese string literal.

Tests

Tests that read an error body read v["text"] or the code; the ones that
asserted on Chinese sentences assert on the English or, where there is one, on
the code.

Still Chinese

tw-adopt, tw-config, tw-yaml, tw-engine, tw-scan, tw-pricing,
tw-dialect and the twcore CLI — about 350 strings.

Verified

cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (78 suites, 0 failures) and
./scripts/smoke.sh (51 passed, 0 failed).

🤖 Generated with Claude Code

…sentence

An HTTP error from the control plane was a plain-text body, so the
desktop app could only paste it on screen. In a window that ships in two
languages, that sentence is unreadable to half the people who see it.

`Fail` is `(StatusCode, Json<Msg>)` now: the body carries a code, the
arguments that fill the sentence, and the English text. The app looks up
the code in its own dictionary and falls back to the text for one it
does not know.

About 250 strings across the crate are English, and the error paths carry
a code — `control.upstream_not_found`, `control.default_key_delete`,
`control.callback_ports_busy`, and so on. Three helpers keep the common
cases short: `internal` for a database or serialization failure that the
app can only report, `no_such_upstream` for the lookup that eight
handlers repeat, and `checked_name` / `slug`, which now take the English
name of the resource kind and put it in `args` so the app can pick its
own word for it.

Two surfaces beyond the envelope:

- The diagnostics bundle is English Markdown. It is a document a person
  reads before pasting it into an issue, and issues in this repository
  are in English.
- The ChatGPT sign-in callback pages are English, and the page that
  carries them stopped claiming `lang="zh-CN"`.

`crates/tw-control/src` no longer contains a Chinese string literal.

Tests that read an error body read `v["text"]` or the code; the ones that
asserted on Chinese sentences assert on the English or, where there is
one, on the code.

Still Chinese, and not in this change: `tw-adopt`, `tw-config`,
`tw-yaml`, `tw-engine`, `tw-scan`, `tw-pricing`, `tw-dialect` and the
`twcore` CLI — about 350 strings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 7f840af into main Sep 20, 2026
1 check passed
@fylorn
fylorn deleted the i18n/control branch September 20, 2026 06:08
This was referenced Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant