Skip to content

fix: localize external link aria labels#18

Merged
afc163 merged 2 commits into
mainfrom
codex/aria-label-i18n
Jul 1, 2026
Merged

fix: localize external link aria labels#18
afc163 merged 2 commits into
mainfrom
codex/aria-label-i18n

Conversation

@afc163

@afc163 afc163 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add localized data-aria-zh / data-aria-en values for external links that open in a new window.
  • Update the language switcher to sync aria-label alongside visible text.
  • Add a Node test that guards external-link aria-label localization.

Closes #15

Verification

  • npm test
  • npx biome lint index.html js/i18n.js tests/aria-label-i18n.test.mjs
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Enhanced multilingual accessibility for external links by adding language-aware “open in new window” labeling to improve screen-reader clarity in both Chinese and English.
  • Tests
    • Added automated checks to ensure external links include the new accessibility/i18n attributes and that the correct language-specific aria labeling is applied.
  • Chores
    • Added a test script to run the Node-based test suite.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploying afx-team with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0760e75
Status: ✅  Deploy successful!
Preview URL: https://0cf54061.afx-team.pages.dev
Branch Preview URL: https://codex-aria-label-i18n.afx-team.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 33612b47-3080-4740-9028-32c63134f8a2

📥 Commits

Reviewing files that changed from the base of the PR and between 947f675 and 0760e75.

📒 Files selected for processing (2)
  • index.html
  • tests/aria-label-i18n.test.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/aria-label-i18n.test.mjs
  • index.html

📝 Walkthrough

Walkthrough

Adds data-aria-zh/data-aria-en attributes to external links across several sections of index.html, extends updateDOMContent(lang) in js/i18n.js to sync aria-label with the active language, adds a test npm script, and adds a new test file validating the link attributes and i18n script behavior.

Changes

Aria-label localization

Layer / File(s) Summary
I18nManager aria-label update logic
js/i18n.js
updateDOMContent(lang) gains a DOM pass over elements with data-aria-zh/data-aria-en attributes, setting aria-label to the corresponding localized string based on active language.
External link attributes across sections
index.html
Anchors in “最新动态”, “对外产品”, “开源产品”, “待招聘岗位”, and “关注我们” sections gain data-aria-zh/data-aria-en (and in places data-zh/data-en) attributes, with aria-label strings adjusted accordingly while URLs and visible text stay unchanged.
Test script and aria-label test coverage
package.json, tests/aria-label-i18n.test.mjs
A test script (node --test) is added, and a new test file parses index.html external links to assert presence and consistency of aria-label/data-aria-zh/data-aria-en, checks English values contain no Chinese characters, and verifies js/i18n.js implements the data-aria-* switching logic.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant I18nManager
  participant DOMElement

  User->>I18nManager: switch language (zh/en)
  I18nManager->>DOMElement: read data-aria-zh / data-aria-en
  I18nManager->>DOMElement: setAttribute('aria-label', localizedValue)
  I18nManager->>DOMElement: update textContent via data-zh/data-en
Loading

Related issues: #15 (feat: aria-label 国际化支持)

Suggested labels: accessibility, i18n, tests

Suggested reviewers: afx-team maintainers familiar with index.html and js/i18n.js

🐇 A rabbit hops through links so bright,
Whispering labels in day or night,
Chinese by morn, English by noon,
Aria-labels now sing in tune,
Tests stand guard to keep it right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: localizing external-link aria labels.
Linked Issues check ✅ Passed The changes add data-aria localization and sync aria-label updates as requested in #15, with tests covering the behavior.
Out of Scope Changes check ✅ Passed The added test and package.json script support the requested aria-label localization work and do not introduce unrelated changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/aria-label-i18n

Comment @coderabbitai help to get the list of available commands.

@afc163 afc163 force-pushed the codex/aria-label-i18n branch from 4e5bc39 to 947f675 Compare July 1, 2026 11:46
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

♻️ Preview destroyed

PR preview ♻️ Destroyed ♻️ Destroyed
🔗 Preview https://afx-team-afx-team-github-io-preview-pr-18.surge.sh (already destroyed)
📝 Commit0760e75
🪵 LogsView logs

🤖 Powered by surge-preview

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces localized ARIA labels for external links to improve accessibility. It adds data-aria-zh and data-aria-en attributes to anchor tags in index.html, updates js/i18n.js to dynamically toggle the aria-label based on the active language, and adds a test suite to verify this behavior. Review feedback points out a minor inconsistency in index.html where the square brackets are missing from the Chinese ARIA attributes for the 'Mako Next' link.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread index.html
<div>
<h3 class="font-semibold text-base mb-1 tracking-wide">
<a href="https://mp.weixin.qq.com/s/CdCvCzfycme6rw4OKa_1aA" target="_blank" rel="noopener noreferrer" class="text-gray-700 hover:text-black" aria-label="MCP 在蚂蚁前端的落地之旅 - 在新窗口打开" data-zh="MCP 在蚂蚁前端的落地之旅" data-en="MCP Landing Journey in Ant Frontend">MCP 在蚂蚁前端的落地之旅</a>
<a href="https://mp.weixin.qq.com/s/CdCvCzfycme6rw4OKa_1aA" target="_blank" rel="noopener noreferrer" class="text-gray-700 hover:text-black" aria-label="MCP 在蚂蚁前端的落地之旅 - 在新窗口打开" data-aria-zh="MCP 在蚂蚁前端的落地之旅 - 在新窗口打开" data-aria-en="MCP Landing Journey in Ant Frontend - Open in new window" data-zh="MCP 在蚂蚁前端的落地之旅" data-en="MCP Landing Journey in Ant Frontend">MCP 在蚂蚁前端的落地之旅</a>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The aria-label and data-aria-zh attributes are missing the square brackets [ and ] around Mako Next, which is inconsistent with the visible text [Mako Next]: ... and the English equivalent data-aria-en="[Mako Next]: ...". Adding them ensures consistency across all localized labels.

Suggested change
<a href="https://mp.weixin.qq.com/s/CdCvCzfycme6rw4OKa_1aA" target="_blank" rel="noopener noreferrer" class="text-gray-700 hover:text-black" aria-label="MCP 在蚂蚁前端的落地之旅 - 在新窗口打开" data-aria-zh="MCP 在蚂蚁前端的落地之旅 - 在新窗口打开" data-aria-en="MCP Landing Journey in Ant Frontend - Open in new window" data-zh="MCP 在蚂蚁前端的落地之旅" data-en="MCP Landing Journey in Ant Frontend">MCP 在蚂蚁前端的落地之旅</a>
<a href="https://github.com/umijs/mako/issues/1872" target="_blank" rel="noopener noreferrer" class="text-gray-700 hover:text-black" aria-label="[Mako Next]: A new bundler on top of Turbopack - 在新窗口打开" data-aria-zh="[Mako Next]: A new bundler on top of Turbopack - 在新窗口打开" data-aria-en="[Mako Next]: A new bundler on top of Turbopack - Open in new window" data-zh="[Mako Next]: A new bundler on top of Turbopack" data-en="[Mako Next]: A new bundler on top of Turbopack">[Mako Next]: A new bundler on top of Turbopack</a>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0760e75: the Mako Next aria-label and data-aria-zh now preserve the square brackets, matching the visible/data title.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/aria-label-i18n.test.mjs (1)

1-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Solid coverage; consider also asserting aria-label mirrors visible title text.

Current test only checks aria-label === data-aria-zh, not that it matches the anchor's actual visible text/data-zh. That would have caught the bracket-omission mismatch on the Mako Next entry in index.html.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/aria-label-i18n.test.mjs` around lines 1 - 51, The aria-label coverage
in aria-label-i18n.test.mjs only checks against data-aria-zh, so extend the
external link assertions to also verify the anchor’s aria-label matches its
visible localized title text/data-zh from index.html. Update getExternalLinks or
the loop in the test to capture the link text/visible label and compare it with
aria-label so mismatches like the Mako Next bracket omission are caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@index.html`:
- Line 234: The anchor in the main HTML content has mismatched accessible text
because the aria-label and data-aria-* values omit the square brackets that are
present in the visible link title and data-zh/data-en strings. Update the link’s
accessibility metadata in the anchor element so aria-label, data-aria-zh, and
data-aria-en exactly match the rendered title “[Mako Next]: A new bundler on top
of Turbopack”, keeping the visible text and all localized variants consistent.

---

Nitpick comments:
In `@tests/aria-label-i18n.test.mjs`:
- Around line 1-51: The aria-label coverage in aria-label-i18n.test.mjs only
checks against data-aria-zh, so extend the external link assertions to also
verify the anchor’s aria-label matches its visible localized title text/data-zh
from index.html. Update getExternalLinks or the loop in the test to capture the
link text/visible label and compare it with aria-label so mismatches like the
Mako Next bracket omission are caught.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dbc2c84a-e65d-472c-9b7f-7998b4eb33df

📥 Commits

Reviewing files that changed from the base of the PR and between 5da4f09 and 947f675.

📒 Files selected for processing (4)
  • index.html
  • js/i18n.js
  • package.json
  • tests/aria-label-i18n.test.mjs

Comment thread index.html Outdated
@afc163 afc163 merged commit 048a3b3 into main Jul 1, 2026
3 checks passed
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.

feat: aria-label 国际化支持

1 participant