Skip to content

fix(a11y): name diagrams and the table of contents in the page language - #58

Merged
QingYunA merged 3 commits into
QingYunA:mainfrom
kevin9327:fix/aria-labels-page-language
Oct 5, 2026
Merged

QingYunA merged 3 commits into
QingYunA:mainfrom
kevin9327:fix/aria-labels-page-language

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Summary

Fixes #47.

On English and Japanese pages, screen readers announced three accessible names in Chinese: flow diagrams (流程图:…), sequence diagrams (时序图:…), and the doc template's table of contents (目录).

  • src/render.js: the UI label table gets toc, flow, sequence and a list separator sep for zh / en / ja. The page language is now worked out before the panels are rendered. The UI strings go to components through the render context and to templates as ui.
    • en: Contents, Flowchart: A, B, Sequence diagram: A, B
    • ja: 目次, フローチャート:A、B, シーケンス図:A、B
    • zh: unchanged
  • src/components/flow.js and src/components/sequence.js: the aria-label uses ui.flow / ui.sequence and joins names with ui.sep. When a component is rendered without a context, as in the component unit tests, it falls back to English. The lang-ok markers for Page aria-labels are always Chinese (flow, sequence, doc table of contents) #47 are gone.
  • src/templates/doc.js: the TOC aria-label uses ui.toc.
  • src/video/render.js: video scenes pass the same page labels, so a diagram in a video draft is named in the draft's language too.
  • test/render.test.js: the new test renders an en, a zh and a ja doc draft with a flow, a sequence and 3 panels. It checks all three labels for each language. It fails on main.

Verification

  • npm test passes (287 pass, 3 skipped, 0 fail)
  • Ran npm run build and committed the rebuilt am.mjs
  • npm run snapshot: 120 of 336 combinations differ from origin/main, all intended. Every difference is in the en example drafts (tcp.en.md, ste100.md). I rendered each example with both versions and diffed the output: only aria-label values change, from 目录 → Contents, 时序图:Client、Server → Sequence diagram: Client, Server, and 流程图:CLOSED、LISTEN、… → Flowchart: CLOSED, LISTEN, …. The zh examples (tcp.md, architecture.md) render identically.
  • Screenshot attached (no visual change)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

The UI table held 'Flowchart: ' with its colon and trailing space, so the
label text and the punctuation could not change on their own. Store the
name, the colon and the list separator as separate entries, and build the
label in one helper, diagramLabel(), used by flow and sequence. The English
fallback for a component rendered without a page context now lives in that
helper only. Add a test for the fallback.
@QingYunA
QingYunA merged commit 03fd531 into QingYunA:main Oct 5, 2026
15 of 16 checks passed
@QingYunA

QingYunA commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Thanks @kevin9327, this is a clean fix for #47. Moving the labels into the UI table and passing them through the render context keeps zh / en / ja in one place, and the test that fails on main is a good guard.

I pushed one commit on top of your branch (fc5dac0) for a small cleanup:

  • The label names no longer carry their punctuation. UI now holds the name (Flowchart), the colon (: / :) and the list separator as separate entries, so each can change without touching the others.
  • A new helper, diagramLabel() in src/svg/shapes.js, builds the label for both flow and sequence. The English fallback for a component rendered without a page context now lives only there.
  • A test covers that fallback.

I merged the latest main into the branch first and rebuilt the bundle. All checks pass. One coverage run failed on a timing assertion in test/layout-plan.test.js that also fails on main, and it passed on re-run, so it is unrelated to this PR.

Merged with a squash, so main keeps one commit.

@QingYunA QingYunA mentioned this pull request Oct 5, 2026
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.

Page aria-labels are always Chinese (flow, sequence, doc table of contents)

2 participants