Skip to content

404 page: the site header and footer follow the visitor's language too - #48

Merged
fylorn merged 1 commit into
mainfrom
fix/404-bilingual-chrome
Oct 1, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/404-bilingual-chrome

Conversation

@fylorn

@fylorn fylorn commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

GitHub Pages serves one 404 page for every address, built as an English page. Its script switched the body to Chinese for Chinese visitors, but the header, the footer and the search box stayed English.

  • SiteHeader, SiteFooter and SearchModal take a bilingual prop, which only the 404 page sets. With it:
    • every piece of text is rendered in both languages, through a small Bi component;
    • links carry data-localize, so the page's script points them at /zh-CN;
    • attributes that are not text (aria-labels, and the search box's placeholder, hints and scope labels) carry their Chinese values in data-zh-attrs, which the script swaps in;
    • the language menu marks the visitor's language.
  • Every other page renders exactly as before. The header, footer and search dialog of the live Chinese home page and a docs page are identical to this build's, ignoring Astro's scope ids and the star count.

Checked in headless Chromium:

  • Chinese 404 at 1440 px: navigation, button, logo link, language menu, search texts, burger label and footer are all Chinese, and the links lead to /zh-CN/….
  • English 404: unchanged.
  • 390 px: the opened mobile menu is Chinese.
  • tsc --noEmit is clean.

🤖 Generated with Claude Code

GitHub Pages serves one 404 page for every address, built as an English
page; its script switched the body to Chinese, but the header, the
footer and the search box stayed English.

SiteHeader, SiteFooter and SearchModal take a `bilingual` prop, set only
by the 404 page. With it, every piece of text is rendered in both
languages (a small Bi component), links carry data-localize for the
page's script to point at /zh-CN, attributes such as aria-labels and the
search box's texts carry their Chinese values in data-zh-attrs, and the
language menu marks the visitor's language. Every other page renders
exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 80238a1 into main Oct 1, 2026
1 check passed
@fylorn
fylorn deleted the fix/404-bilingual-chrome branch October 1, 2026 05:53
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.

1 participant