Skip to content

feat(metals): render Metals v0.1.1 labels from translation.json (#331) - #342

Merged
stiebitzhofer merged 9 commits into
mainfrom
feat/metals-v011-translated-labels-331
Oct 6, 2026
Merged

stiebitzhofer merged 9 commits into
mainfrom
feat/metals-v011-translated-labels-331

Conversation

@stiebitzhofer

Copy link
Copy Markdown
Member

Closes #331.

What

Metals v0.1.1 certificate labels now come from translation.json. When a certificate lists DE, labels are joined as "Cast Number / Gussnummer"; an English-only certificate renders text-identically to before.

  • Stylesheet: new mi:label(key, fallback), used for 99 fixed labels plus three data-driven lookups (production identifier types, tolerance rows, Order/Delivery/Contract). The fallback is today's English literal. No xsl:import.
  • Loader: pattern broadened to translation*.json (SchemaControllerConstants); WatermarkManager now uses it as-is. The file is not renamed.
  • Key sanitising (not in the issue, needed): with the broader pattern, Metals keys such as 1/4T and Quenching and Tempering made rendering fail ("Failed to parse XML securely"). XmlKeySanitizer is ported from material-identity/schema and applied in TranslationLoader. Other families' keys are already legal and pass through unchanged (covered by a test).
  • Header height: +0.7 cm when a certificate lists more than one language, so the joined title doesn't overlap the parties band. EN-only and DE-only are unaffected.
  • translation.json: 35 keys added to EN and DE; no existing EN wording changed.

Fixtures

  • New valid_bilingual_labels (EN+DE).
  • 14 existing fixtures listed DE although nothing rendered it. 7 of them, picked at random, are set back to ["EN"] and keep their pre-change PDFs byte for byte. The other 7 (basic_certificate, dimensional_tolerances, product_analysis, product_shapes, production_identifiers, word_wrap_breaks, DE-only physical_properties) are re-baselined. A word diff shows only added German label text and " / ".

Gates

Gate Result
Interfer, both certificates, json2pdf.js --xsltPath, main vs branch text identical
jest test/metals-labels.spec.js (every key in EN and DE; EN equals fallback) 332 passed
npx jest 605 passed, 3 skipped
mvn test -Dtest=RenderTest,TranslationLoaderTest 141/142; the one error is the S3-only Bluemint fixture missing from a fresh worktree, unrelated
Metals v0.0.1 / v0.1.0 re-render identical
Watermark text unchanged

Mirror PR in material-identity/schema follows (byte-identical Metals/v0.1.1; Interfer compareCustomer 30/0, Everest 37/0).

Please review

  • German wording of the new labels (follows DMP v1.0 de.yaml where possible; no domain or print review yet).
  • Left in English: Yes/No, words inside values ("min.", "max.", "per"), purity-matrix rows from data, the logo alt-text.
  • Average, Parameter, Status are also schema property names, so the editor will show German labels for them.

🤖 Generated with Claude Code

stiebitzhofer and others added 3 commits October 3, 2026 23:46
The stylesheet printed every label as fixed English text and the renderer
never loaded Metals' singular translation.json, so German labels such as
"Gussnummer" never reached the PDF.

- loader: JSON_TRANSLATIONS_FILE_NAME_PATTERN broadened to
  translation*.json (as WatermarkManager already did, which now uses the
  pattern as given); the file is not renamed
- TranslationLoader makes keys legal XML names (XmlKeySanitizer, ported
  from material-identity/schema :legacy): Metals' translation.json has enum
  keys such as "1/4T" that otherwise break the JSON -> XML step. Every
  other family's keys are already legal and pass through unchanged
- stylesheet: mi:label(key, fallback) reads Root/Translations and falls
  back to today's literal; 99 static lookups plus production identifier
  types, tolerance rows and Order/Delivery/Contract. Every key's EN value
  equals its fallback, so EN-only certificates render text-identically
  (all 15 EN-only fixtures and both Interfer certificates diffed against
  a render from main: identical)
- the header region grows by 0.7cm only when a certificate lists more
  than one language, so the joined title no longer overlaps the body
- translation.json: 35 label keys added to EN and DE (EN = fallback);
  existing EN wording untouched
- re-baselined the 14 v0.1.1 fixture PDFs that list DE: their labels now
  read "EN / DE" (or German only). A token-level check shows no value
  changed; bilingual pages may run onto a second page
- new fixture valid_bilingual_labels (EN+DE, "Cast Number / Gussnummer")
- test/metals-labels.spec.js: every looked-up key exists in EN and DE and
  its EN value equals the stylesheet fallback; TranslationLoaderTest
  covers loading, joining, sanitizing and the unchanged watermark text

Values, enum rendering (CastingMethod raw), Yes/No and in-value wording
("min.", "per", "Width" in the shape line) are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fourteen Metals v0.1.1 fixtures listed DE although nothing ever rendered it,
so #331 turned their labels bilingual. Half of them, picked at random, go back
to Languages ["EN"] and keep their pre-#331 reference PDFs byte for byte:
country_of_melt_and_pour, individual_statements, mechanical_properties,
regulatory_markings, result_types, statement_links, supplementary_tests.
Bilingual coverage stays with the other six EN+DE fixtures, the DE-only
physical_properties fixture and valid_bilingual_labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rderId (material-identity/schema#426)

The Metals v0.1.1 certificate dropped both fields silently. They now print on
the grey detail line under the Order and Delivery rows, labelled through
mi:label (EN "Customer Product Name" / "Internal Order ID", DE from
translation.json), and only when present: a certificate without them renders
exactly as before (Interfer 30/30 and Everest 37/37 unchanged).

Re-baselines the 19 Metals v0.1.1 fixtures that carry InternalOrderId (text
diff is additions only, plus one note moving across a page break in
product_shapes and word_wrap_breaks). valid_extruded_aluminium_profile gains
a CustomerProductName so both fields are covered.

Builds on the #331 translated-labels branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stiebitzhofer and others added 3 commits October 4, 2026 10:19
…key collides (#331)

XmlKeySanitizer let the first key take a contested name, so "a b" before
"a_b" took a_b and the stylesheet would read the wrong value. Keys that are
already legal XML names now own their name; a rewritten key moves aside
with a "_" prefix. Key order is preserved. The test asserts the values,
not just that both names exist. No translation file has such a pair today
(review finding on #342).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…non-empty (material-identity/schema#426)

The guards tested for the element only, so "InternalOrderId": "" printed
"Internal Order ID: " with nothing after it. normalize-space() also skips
whitespace-only values. No fixture changes: every committed fixture carries
non-empty values (review finding on #343).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asamark

asamark commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Why would Interfer case be different here? They are also using Language property in the certificates

@asamark asamark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any change specific to Interfer, I assume they will always use the fallback case. Just the github issue mentioned them

@stiebitzhofer

Copy link
Copy Markdown
Member Author

Why would Interfer case be different here? They are also using Language property in the certificates

Yes, the have been there all the time. However, the translations have never been applied. All the Interfer examples in https://github.com/material-identity/schema/tree/main/customers/Interfer render without any difference.

…ds-426

feat(metals): render Order.CustomerProductName and Delivery.InternalOrderId (schema#426)
@eamon0989
eamon0989 temporarily deployed to s1-schemas-pr-342 October 5, 2026 11:07 Inactive
@stiebitzhofer
stiebitzhofer requested review from asamark and eamon0989 and removed request for asamark and eamon0989 October 5, 2026 11:08
@stiebitzhofer
stiebitzhofer merged commit 0da6c7a into main Oct 6, 2026
12 checks passed
@stiebitzhofer
stiebitzhofer deleted the feat/metals-v011-translated-labels-331 branch October 6, 2026 09:06

This branch was previously deployed

1 inactive deployment
s1-schemas-pr-342 — f71ea92f Deployed Oct 5, 2026 by eamon0989
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.

Metals v0.1.1: render certificate labels from translations, with no impact on Interfer

3 participants