Skip to content

fix(i18n): fall back when request language is missing - #13

Merged
TechQuery merged 1 commit into
mainfrom
agent/fix-ssr-language-fallback
Aug 9, 2026
Merged

fix(i18n): fall back when request language is missing#13
TechQuery merged 1 commit into
mainfrom
agent/fix-ssr-language-fallback

Conversation

@FenjuFu

@FenjuFu FenjuFu commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR-13 PR-13 PR-13 Powered by Pull Request Badge

Summary

  • fall back to the built-in zh-CN translation map when a request has no supported language
  • prevent SSR pages, the root layout, and metadata generation from failing for probes, crawlers, and clients without Accept-Language

Root cause

mobx-i18n returns undefined when neither the language cookie nor Accept-Language matches a configured language. The app destructured that result unconditionally, so every page render threw before producing HTML.

Impact

Requests without a supported language now render in Simplified Chinese instead of returning HTTP 500. Existing zh-CN, zh-TW, and en-US negotiation remains unchanged.

Verification

  • pnpm exec next build
  • pnpm exec prettier --write i18n/index.ts
  • pnpm exec eslint i18n/index.ts
  • pnpm exec tsc --noEmit
  • production server requests to /home: no language header -> 200 / zh-CN; zh-CN -> 200 / zh-CN; en-US -> 200 / en-US

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Cloudflare Preview Deployment

  • Branch: agent/fix-ssr-language-fallback
  • Commit: 669ce7c
  • Preview Alias: b-agent-fix-ssr-language-fallback

Wrangler Output

Uploaded 1 of 1 asset
✨ Success! Uploaded 1 file (56 already uploaded) (1.22 sec)
Uploaded goodaction-hub (8.69 sec)
Worker Version ID: bed385c3-55d0-4fcd-8754-ed2196a22808
Version Preview URL: https://bed385c3-goodaction-hub.shiy2008.workers.dev
Version Preview Alias URL: https://b-agent-fix-ssr-language-fallback-goodaction-hub.shiy2008.workers.dev

@TechQuery TechQuery added the bug Something isn't working label Aug 9, 2026
@github-project-automation github-project-automation Bot moved this from Todo to In Review in GoodActionHub 官网开发 Aug 9, 2026
@TechQuery
TechQuery merged commit 18a7276 into main Aug 9, 2026
3 checks passed
@TechQuery
TechQuery deleted the agent/fix-ssr-language-fallback branch August 9, 2026 13:48
@github-project-automation github-project-automation Bot moved this from In Review to Done in GoodActionHub 官网开发 Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants