Skip to content

Add Simplified Chinese localization and language switching - #336

Closed
wututua wants to merge 1 commit into
lissy93:masterfrom
wututua:master
Closed

Add Simplified Chinese localization and language switching#336
wututua wants to merge 1 commit into
lissy93:masterfrom
wututua:master

Conversation

@wututua

@wututua wututua commented Aug 23, 2026

Copy link
Copy Markdown

Summary

This PR adds Simplified Chinese (zh-CN) localization and an English/Chinese language switcher across Web Check.

Changes

  • Added a shared localization system for React views and result components
  • Added language switchers to both React and Astro pages
  • Added Simplified Chinese translations for:
    • Home, results, About, and error pages
    • All 39 check descriptions and result fields
    • Loading, progress, advisory, empty, and error states
    • Account, API overview, and self-hosted setup pages
    • Navigation, footer, buttons, tooltips, and accessibility labels
  • Detects the browser language on first visit
  • Persists the selected language in localStorage
  • Updates the document language through the lang attribute
  • Allows switching languages without restarting an active scan
  • Keeps technical values such as CVEs, protocols, domain names, and product names untranslated

Additional Fix

While testing the production server locally on Windows, I found that absolute filesystem paths were passed directly to ESM import() calls. This PR converts them to proper file URLs using fileURLToPath and pathToFileURL, allowing the local production server and API routes to start correctly on Windows.

Testing

  • yarn typecheck
  • yarn lint
  • yarn build
  • Prettier check for all modified files
  • Local production health check
  • English and Chinese switching
  • Language persistence after reload and navigation
  • Desktop layout at 1440×900
  • Mobile layout at 390×844
  • Verified /check, /check/about, /account, /web-check-api, and /self-hosted-setup
  • No browser console errors or horizontal overflow

No new runtime dependencies were added.

@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploy Preview for web-check ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2f9858d
🔍 Latest deploy log https://app.netlify.com/projects/web-check/deploys/6a8b1a5eb61dfe0008f13de4
😎 Deploy Preview https://deploy-preview-336--web-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@lissy93 lissy93 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the PR @wututua
But I cannot merge this. It's not maintainable.

I'll find a better system for internationalization, which doesn't involve any inline if statements. web-check is hand-written, so I won't merge an AI PR which is of poor quality.

Comment on lines +106 to 119
<Button>{isChinese ? '返回首页' : 'Go back Home'}</Button>
</Link>
<a target="_blank" rel="noreferrer" href="https://github.com/lissy93/web-check">
<Button>View on GitHub</Button>
<Button>{isChinese ? '在 GitHub 查看' : 'View on GitHub'}</Button>
</a>
</HeaderLinkContainer>
</Nav>
<ErrorInner>
<Heading as="h1" size="medium" color={colors.primary}>
Something's gone wrong
{isChinese ? '出现了一些问题' : "Something's gone wrong"}
</Heading>
<Heading as="h2" size="small" color={colors.textColor}>
An unexpected error occurred.
{isChinese ? '发生了意外错误。' : 'An unexpected error occurred.'}
</Heading>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

So, when we add new languages, the markup will have 10+ inline if statements for each language? 🤔️

@lissy93 lissy93 closed this Aug 25, 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.

2 participants