Skip to content

i18n: parameter schema errors translate what the value must be - #7038

Merged
bflatastic merged 2 commits into
storytold:mainfrom
dotCooCoo:fix/schema-expected-phrases
Nov 13, 2026
Merged

bflatastic merged 2 commits into
storytold:mainfrom
dotCooCoo:fix/schema-expected-phrases

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What and why

A parameter schema's error, such as "invalid parameters for view.saved.new: zoom must be a number > 0, not -1", was translated around its requirement. The requirement stayed in English in every language, because the catalogs had rows only for "a number", "a string" and "true or false". Translating the whole requirement is VectorCraft's own rule.

  • Every catalog that translates all status and error messages gets a row for each requirement a schema writes (crates/apischema/src/lib.rs): a number with each kind of range, with and without a unit; an integer and its range; a list of names (one of {_1}); an object id; a list of object ids; a color; a point; an object; and a list. The bounds, the unit and the names stay as the English gives them.
  • An error for a value that is not one of its names matched the `{key}` must be one of {_1} row first, which took "left", "center", "right", not "top" as its list and left ", not ..." in English. A new `{path}` must be one of {_1}, not {got} row translates it, in the same catalogs and in Bulgarian, Bosnian, Danish, Indonesian and Dutch.
  • message (crates/ui-egui/src/i18n.rs) left every part of a message that starts with { or [ untranslated, so "[x, y] (two numbers)" could not be translated. Such a part is now translated only when it has an exact @msg row (Catalog::exact_message); JSON values, whole or cut short, stay as they are.
  • docs/mcp.md (Parameter schemas) says the status bar shows these errors in the interface language and the command API returns them in English. docs/target-app-parity.md has one line for the change.

The command API, the CLI and MCP still return the English text. vectorcraft-apischema is a new dev-dependency of vectorcraft-ui-egui, with its Cargo.lock line.

How it was tested

Tests in crates/ui-egui/src/i18n/tests.rs, each failing without the change:

  • parameter_schema_errors_are_translated (extended): view.saved.new errors with a bad zoom, a bad point and a number with a unit show their requirement translated in every complete-message language, with the path and the refused value kept.
  • parameter_schema_expected_phrases_are_translated (new): 32 requirements from one-parameter schemas, covering every range and unit form with fractional and negative bounds and a three-name and a one-name list, and one more error at a nested path (edits[1].zoom), 33 errors in all. For each language it checks that the row exists, that the captured bounds, unit and names equal the source in order, and that the error keeps its path and value and holds no English requirement, "must be" or ", not ". It also checks the names error in every catalog other than English.
  • bracketed_message_parts_translate_only_as_exact_messages (new): "[x, y] (two numbers)" is translated, and a captured JSON object or array is left as it is.

Before the rows were added the three tests failed (in Czech "a number > 0" stayed English); with the old {/[ rule put back, all three failed on "[x, y] (two numbers)".

Focused checks on Linux x86-64 with rustc 1.100.0, on the change on main at 39f7d33e22:

  • cargo fmt --all -- --check
  • cargo check --workspace --tests --locked
  • cargo clippy -p vectorcraft-ui-egui --all-targets -- -D warnings
  • cargo test -p vectorcraft-ui-egui --lib i18n: 95 passed, 0 failed

The branch is one commit on main at e899f3fdb4; the docs/mcp.md paragraph goes after the one main added about nesting depth. On that tree, cargo test -p vectorcraft-ui-egui --lib i18n passes again (95 passed, 0 failed). It conflicts with open #1532 and #1963 in the vectorcraft-ui-egui entry of Cargo.lock.

  • cargo xtask brands; cargo xtask layers (30 crates); cargo xtask assets (337 files)
  • cargo xtask ci runs in this pull request's CI.

cargo xtask ci passed in this pull request's CI run on c84ece827c: https://github.com/storytold/vectorcraft/actions/runs/43362847604/job/131680176464. The gate on 6886198458 is pending.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md.

Summary by CodeRabbit

  • Bug Fixes
    • Parameter validation errors in the desktop status bar now translate expected-value messages, including requirements for numbers, ranges, units, integers, and enum choices. Parameter paths, rejected values, bounds, units, and names remain in English.
    • Bracketed values embedded in errors are preserved, while exact matching catalog messages can be translated.
  • Documentation
    • Clarified that command API errors are returned in English; the desktop status bar displays errors in the interface language.

A parameter schema's error ("`zoom` must be a number > 0, not -1") was
translated around its requirement, which stayed in English in every
language: only "a number", "a string" and "true or false" had rows.

- Every complete catalog gets a row for each requirement a schema
  writes: a number with each kind of range and with a unit, an integer
  and its range, a list of names, an object id, a list of object ids,
  a color, a point, an object and a list. The bounds, unit and names
  stay as the English gives them.
- An enum error no longer matches the `{key}` must be one of {_1} row,
  which took `"a", "b", not "c"` as its list and left ", not ..." in
  English: a `{path}` must be one of {_1}, not {got} row translates it,
  in the complete catalogs and in Bulgarian, Bosnian, Danish,
  Indonesian and Dutch.
- A part of a message that starts with `{` or `[` is translated only
  when it is an exact message, so "[x, y] (two numbers)" translates and
  JSON values, shown cut short or whole, stay as they are.

Docs: docs/mcp.md (Parameter schemas), docs/target-app-parity.md.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The UI translation code adds exact catalog lookup for nested values that begin with { or [. Tests cover parameter-schema error phrases and retained values. Documentation describes English command API errors and localized desktop status-bar messages.

Changes: Schema Error Translation

Layer / File(s) Summary
Nested message lookup
crates/ui-egui/src/i18n/catalog.rs, crates/ui-egui/src/i18n.rs
Catalog::exact_message looks up exact catalog entries. Above depth one, message_at uses this lookup for nested values beginning with { or [. Unmatched values remain unchanged.
Schema error coverage and documentation
crates/ui-egui/Cargo.toml, crates/ui-egui/src/i18n/tests.rs, docs/mcp.md, docs/target-app-parity.md
Tests cover schema error phrases, translations, and preservation of parameter paths and rejected values. The documentation describes error localization and retained English details. The UI crate adds vectorcraft-apischema as a development dependency.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: Minimal · up to c84ec

This change translates parameter-schema error messages in the desktop status bar and leaves JSON values and parameter paths unchanged. It does not alter the command API, CLI, or MCP behavior, which stay in English. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: parameter schema error messages now translate the requirement (what the value must be). It matches the changeset, which adds catalog rows for schema requirements and a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template with the sections "What and why", "How it was tested", and "Checklist". It explains the problem (parameter-schema requirements left in English), lists t…
Full details: Title check

Explanation

The title names the main change: parameter schema error messages now translate the requirement (what the value must be). It matches the changeset, which adds catalog rows for schema requirements and a exact-message lookup for bracketed parts. It is specific and concise.

Full details: Description check

Explanation

The description follows the repository template with the sections "What and why", "How it was tested", and "Checklist". It explains the problem (parameter-schema requirements left in English), lists the catalog rows and the new exact-match rule for messages starting with { or [, and names the docs changes. The testing section names three new or extended tests, the rationale for each, and the focused checks run with results (95 passed, 0 failed). The checklist items are marked for panic-freedom, clean-room, and assets. The first checklist item (cargo xtask ci passes) is unchecked, and the author states it is pending on the gate for commit 6886198, so the CI status is not confirmed. The description also notes a merge conflict with open PRs #1532 and #1963 in Cargo.lock. The content is specific and mostly complete, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e899f3f and c84ece8.

Files ignored due to path filters: 28

  • Cargo.lock is excluded by !**/*.lock
  • crates/ui-egui/src/i18n/bg.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/bs.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/ca.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/cs.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/da.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/de.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/el.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/es.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/fi.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/fr.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/hi.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/hu.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/id.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/it.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/ja.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/ka.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/ko.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/nl.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/pl.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/pt-br.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/ru.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/sv.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/tr.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/uk.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/vi.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/zh-hans.tsv is excluded by !**/*.tsv
  • crates/ui-egui/src/i18n/zh-hant.tsv is excluded by !**/*.tsv
Files selected for processing: 6

  • crates/ui-egui/Cargo.toml
  • crates/ui-egui/src/i18n.rs
  • crates/ui-egui/src/i18n/catalog.rs
  • crates/ui-egui/src/i18n/tests.rs
  • docs/mcp.md
  • docs/target-app-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@bflatastic
bflatastic merged commit 9ba02d4 into storytold:main Nov 13, 2026
9 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @dotCooCoo! It passed its CI checks.

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.

2 participants