String packs: rich-text entries, language conditions and word rewriting; theme doctor report; translate-mode words

- Rich sentences (a link or button inside text) can be replaced by data: the inventory gives a rich entry `slots`, a pack value places the site's own elements with {e0}, {e1}, ... (each once, the last may be left out; no markup, plural or other parameters). The engine returns a pieces + element order template; the page inventory carries `rich` slot counts.
- Packs may carry `when: { languages }` (applies only while the site shows one of them; `en` matches `en-GB`) and `rewrite: { words }` (whole-word rewording of the site's own text, messages keep their parameters' values; no sentences of the site in the pack). The hook tells the engine the site's language; a rewording pack makes the delivery carry the whole inventory.
- Apps can ship built-in packs (BuiltInPacks) delivered before installed ones; syncStringPacks hands the tabs a delivery at start only when it changed.
- Translate mode words are a function the app supplies (asked at each draw) and gain a `plural` word; host validates `when` and `rewrite` envelopes.
- Theme doctor: every finding says where (token path or CSS rule), what and how to fix, as catalog keys wb.doctor.*; the Theme Builder shows the full report; the import hint is translated. Doctor words are in the 17 supported catalogs.
- waybetter strings check describes conditions and rewrites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-10-01 14:19:36 +07:00
parent 1539cb68e1
commit 6b37744226
33 changed files with 1353 additions and 85 deletions

View file

@ -3,6 +3,8 @@
// are counts, names and paths. The panel reads the translations through the app's i18n instance
// (setShellI18n); tests/panel.test.ts checks that every key the panel uses is here.
import { DOCTOR_MESSAGES } from '../../../runtime/src/themeDoctor.ts';
export const PANEL_MESSAGES = {
'wb.appearance.accent': 'Accent',
'wb.appearance.accentColor': 'Accent color',
@ -764,6 +766,17 @@ export const PANEL_MESSAGES = {
'wb.ui.select.placeholder': 'Choose…',
'wb.ui.stepper.decrease': 'Decrease {label}',
'wb.ui.stepper.increase': 'Increase {label}',
'wb.doctor.title': 'Theme doctor',
'wb.doctor.hint': 'Advice about this theme: lighter ways to do the same, costs and contrast. It only advises; nothing is blocked or changed.',
'wb.doctor.empty': 'Nothing to report: the theme uses tokens and component settings, and nothing in it is costly.',
'wb.doctor.count': '{count, plural, one {# finding} other {# findings}}',
'wb.doctor.kind.lighter': 'A lighter way',
'wb.doctor.kind.performance': 'Performance',
'wb.doctor.kind.accessibility': 'Accessibility',
'wb.doctor.kind.contrast': 'Contrast',
'wb.doctor.where': 'Where',
'wb.doctor.fix': 'Fix',
...DOCTOR_MESSAGES,
} as const;
export type PanelKey = keyof typeof PANEL_MESSAGES;