REUSE: share count-plus-noun formatting across modes #1317

Open
opened 2026-10-07 04:49:09 +00:00 by kayg · 0 comments
Owner

Evidence

Two web surfaces implement the same count-plus-noun plural rule:

  • apps/web/src/lib/files/model.ts:361 exports countLabel(count, singular, plural) and uses the shared formatNumber helper.
  • apps/web/src/lib/money/import-ui.ts:316 defines another countLabel(count, noun) using a direct Intl.NumberFormat call and an s suffix.

The Money helper is used by import findings and can produce the same count label as the Files helper. The similar implementation was not listed in the 2026-09-30 consistency audit. Existing #310 covers attachment wording, which has a separate zero-label contract; this issue is for the reusable count-plus-noun helper.

Rule

The calternal reuse gate says duplicated logic is a defect. The shared UI owns formatting used by more than one mode.

Fix

Give count-plus-noun wording one packages/ui helper with explicit plural and locale options. Keep caller-specific sentence grammar and empty-state wording at the call site. Use the existing shared number-formatting behavior.

Owner

packages/ui owns the shared text-format helper. Files and Money call it.

## Evidence Two web surfaces implement the same count-plus-noun plural rule: - `apps/web/src/lib/files/model.ts:361` exports `countLabel(count, singular, plural)` and uses the shared `formatNumber` helper. - `apps/web/src/lib/money/import-ui.ts:316` defines another `countLabel(count, noun)` using a direct `Intl.NumberFormat` call and an `s` suffix. The Money helper is used by import findings and can produce the same count label as the Files helper. The similar implementation was not listed in the 2026-09-30 consistency audit. Existing #310 covers attachment wording, which has a separate zero-label contract; this issue is for the reusable count-plus-noun helper. ## Rule The calternal reuse gate says duplicated logic is a defect. The shared UI owns formatting used by more than one mode. ## Fix Give count-plus-noun wording one `packages/ui` helper with explicit plural and locale options. Keep caller-specific sentence grammar and empty-state wording at the call site. Use the existing shared number-formatting behavior. ## Owner `packages/ui` owns the shared text-format helper. Files and Money call it.
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal-v0#1317
No description provided.