Repository navigation
i18n: parameter schema errors translate what the value must be - #7038
Conversation
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.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Merged, thanks @dotCooCoo! It passed its CI checks. |
What and why
A parameter schema's error, such as "invalid parameters for
view.saved.new:zoommust 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.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.`{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@msgrow (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.mdhas one line for the change.The command API, the CLI and MCP still return the English text.
vectorcraft-apischemais a new dev-dependency ofvectorcraft-ui-egui, with itsCargo.lockline.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.newerrors with a badzoom, 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
mainat39f7d33e22:cargo fmt --all -- --checkcargo check --workspace --tests --lockedcargo clippy -p vectorcraft-ui-egui --all-targets -- -D warningscargo test -p vectorcraft-ui-egui --lib i18n: 95 passed, 0 failedThe branch is one commit on
mainate899f3fdb4; thedocs/mcp.mdparagraph goes after the onemainadded about nesting depth. On that tree,cargo test -p vectorcraft-ui-egui --lib i18npasses again (95 passed, 0 failed). It conflicts with open #1532 and #1963 in thevectorcraft-ui-eguientry ofCargo.lock.cargo xtask brands;cargo xtask layers(30 crates);cargo xtask assets(337 files)cargo xtask ciruns in this pull request's CI.cargo xtask cipassed in this pull request's CI run onc84ece827c: https://github.com/storytold/vectorcraft/actions/runs/43362847604/job/131680176464. The gate on6886198458is pending.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.Summary by CodeRabbit