Skip to content

refactor(i18n): name plan usage report words as typed text - #967

Merged
penso merged 7 commits into
mainfrom
i18n/usage-report-text
Nov 1, 2026
Merged

penso merged 7 commits into
mainfrom
i18n/usage-report-text

Conversation

@penso

@penso penso commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #955 (base i18n/usage-settings). Merge #955 first; this PR's base then becomes main.

Summary

Part of Phase 2 of docs/i18n.md, following #880's patterns. This PR covers the next herdr-usage item in "What is left": the words a usage report shows. Every provider passed English Strings for section titles, fact labels and values, share labels, balance labels, the windows it names, and the account line, and named count units ("credits") in English. The panel, the Usage section, and the status bar showed these as written. This PR lays the typed foundation and moves the first provider onto it. The other providers follow in their own PRs.

  • herdr_usage::Text (text.rs): either a message ID with arguments (Text::message("usage-wayfinder-routed").arg("models", 2)) or the service's own words (Text::service(..)). The app writes it with usage::text::words, and command output uses usage::text::english. herdr-usage stays free of GPUI and has no messages of its own.
  • Model: Section::Facts and Section::Shares, Balance::label, Kind::Named, and Account's two lines are now Text. Unit::Count holds a typed Count (Credits, Points, Reviews, or a unit only one service uses, such as DIEM), and the app writes it with a plural (usage-amount-*).
  • Wayfinder names every word in usage-wayfinder.ftl, including the plural model counts, the "keys missing" plan line, and the gateway state's offline and dry-run tags. usage-report.ftl starts holding words that several providers share.
  • Transitional: so that each provider's move stays reviewable, the other providers keep their English as Text::service through a temporary From<&str>/From<String> for Text and pair/pairs/share/shares helpers. The diff in those files is only these conversions; no output changes. The provider PRs remove them, and the last one deletes the From impls, so a leftover literal no longer compiles.
  • Checks: fl! checks its IDs at compile time, but a crate below the app can't use it. Instead, usage/tests/report_messages.rs scans herdr-usage for each Text::message ID and the .arg calls chained to it, and checks them against the English files with i18n::takes. usage/tests/words.rs checks that Wayfinder's messages read in English exactly as the provider wrote them, and that counts take their unit's plural and match the crate's English.
  • Leak test: the en-XA test now draws a facts section, a shares section, and a credits balance named by a provider.
  • Layout fix found under en-XA: a fact's value stayed at its natural width, so a longer value ran past the card's edge (see "before" below). It may now shrink, and it wraps against the end side.

No visible change in English.

  • docs/i18n.md is left as main has it: one later change updates its "What is left" list once the open i18n PRs merge.

Screenshots

Native macOS, debug build, isolated sandbox. A local stub Wayfinder gateway serves the fixture from the provider's tests, so the report is real provider output. The OpenRouter card's error line is fixed by #958, which is not in this stack.

en-XA en-XB
Usage section, before before en-XA before en-XB
Usage section, after after en-XA after en-XB
Usage panel, after panel en-XA panel en-XB

Under en-XB, pseudo-bidi drops the space around an isolated placeable ("2sledom"), as noted in #943. That is the pseudo-locale's per-run reversal, not the message.

QA

  • just format
  • just ci on 0ed245d25 (macOS arm64): passed, with its base and origin/main merged in
  • herdr-usage tests (426), including Wayfinder's, which now assert message IDs and arguments
  • Every Text::message in herdr-usage exists with exactly its chained arguments (scan test, with a unit test for the scanner)
  • Wayfinder's English reads as before, for each plural and selector; count units pluralize and match the crate's English
  • en-XA leak test: facts, shares, and a credits balance named by a provider
  • Native en-XA and en-XB: the Usage section and the usage panel (screenshots above)
  • English: Wayfinder's card and panel read as before

🤖 Generated with Claude Code

https://claude.ai/code/session_01BFavh7vQNk6CpU1rxrJkHw

penso added 3 commits October 31, 2026 21:12
Each usage provider's settings carried their help as English in
herdr-usage, which the usage panel's Setup block showed as written.

Setting::help becomes Setting::message, the ID of a message in the
provider's own locales/en-US/usage-<id>.ftl (156 messages across the
providers that read settings). The panel shows it with i18n::message.
One file per provider keeps parallel provider PRs out of each other's
catalogs.

The example config's generated provider section came from the English in
herdr-usage. Its generator and bless test move to the app's usage tests,
which read the English messages. The section is unchanged byte for byte.
A new test checks that every setting names a message without arguments,
and the en-XA leak test no longer allows the help as data.
herdr-usage reports carried English Strings for section titles, fact
labels and values, share labels, balance labels, window names, and the
account line, and count units as English words, which the usage panel
showed whatever the language.

herdr_usage::Text is now the words a report shows: a message ID with
arguments, which the app writes with usage::text::words, or the service's
own words. Count units are a typed Count the app writes with a plural
(usage-amount-*). Wayfinder names all of its words in usage-wayfinder.ftl;
the other providers keep their English through a transitional
From<&str>/From<String> for Text and pair/pairs/share/shares helpers,
which go once the last of them names its words.

A crate below the app cannot use fl!'s compile-time check, so an app test
scans herdr-usage for Text::message IDs and the arguments chained to
them and checks each against the English messages. The en-XA leak test
now draws facts, shares, and a credits balance a provider names.
A fact's value sat at its natural width, so a longer one, as en-XA or
another language writes it, ran past the usage card's edge. The value
may now shrink and wraps under itself, set against the end side.
@penso

penso commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

just ci ran locally and passed on 0ed245d25 (macOS arm64).

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with later message-based CLI window labels covered by PR #968.

Summary

Adds typed report text and count units, then moves Wayfinder's report words into Fluent.

  • Usage reports carry typed words that the app can translate.
  • Wayfinder report labels and status text come from Fluent messages.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Provider[Provider report] --> Text[Text]
    Text --> Service[Service words]
    Text --> Message[Message ID and arguments]
    Service --> UI[Usage views]
    Message --> Fluent[Current-language Fluent text]
    Fluent --> UI
    Text --> English[English account text]
    English --> CLI[CLI output]
Loading

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

penso added 3 commits November 1, 2026 11:02
Every open i18n pull request edits the remaining list in docs/i18n.md, so
each merge made the others conflict. This branch now keeps main's copy;
one change updates the list once they have all merged.
@penso

penso commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

Base automatically changed from i18n/usage-settings to main November 1, 2026 21:20
@penso

penso commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@netlify

netlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for herdr-ui canceled.

Name Link
🔨 Latest commit b2973b8
🔍 Latest deploy log https://app.netlify.com/projects/herdr-ui/deploys/6ae7b1c4c9f2dd0018ce1d74

@penso
penso merged commit 466af2c into main Nov 1, 2026
22 checks passed
@penso
penso deleted the i18n/usage-report-text branch November 1, 2026 21:43
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