Add i18n support with English, Chinese, Spanish, and Japanese#112
Conversation
Implement Fumadocs internationalization following the official i18n pattern: - Add i18n config with en/zh/es/ja locales (lib/i18n.ts) - Create i18n middleware for locale-based routing - Restructure app routes under [lang] dynamic segment - Add UI string translations for all locales in defineI18nUI - Create translated MDX content files for all 3 docs pages - Update source loader, layout options, and search API for locale support - Update .gitignore to allow docs/lib/ directory https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm
Greptile SummaryThis PR implements comprehensive i18n support for the documentation site with English, Chinese (Simplified), Spanish, and Japanese languages. The implementation restructures the routing to use locale-prefixed paths ( Key changes:
Previously identified issues:
The implementation is architecturally sound and follows Next.js i18n best practices. The routing, middleware configuration, and API endpoint updates are all correctly implemented. Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 10fd972 |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Additional Comments (1)
With i18n enabled, As a result, Prompt To Fix With AIThis is a comment left during a code review.
Path: docs/app/og/docs/[...slug]/route.tsx
Line: 10:10
Comment:
**OG images broken for non-English locales**
With i18n enabled, `source.getPage(slug.slice(0, -1))` is called without a locale parameter, so it only resolves pages for the default language (`en`). Meanwhile, `getPageImage(page)` generates URLs based on `page.url` which now includes the locale prefix (e.g., `/zh/docs/api` → `/og/zh/docs/api/og.png`). However, this OG route sits at `/og/docs/[...slug]`, not `/og/[lang]/docs/[...slug]`, so those locale-prefixed OG URLs will never match this route.
As a result, `generateMetadata` in `docs/app/[lang]/docs/[[...slug]]/page.tsx` sets OG image URLs that will 404 for all non-English pages.
How can I resolve this? If you propose a fix, please make it concise. |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Move OG route from /og/docs/[...slug] to /og/[lang]/docs/[...slug] so locale-prefixed OG URLs resolve correctly. Pass lang to source.getPage and strip locale/docs prefix from segments for generateStaticParams. https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm
Move llms.mdx route from /llms.mdx/docs/[[...slug]] to /llms.mdx/[lang]/docs/[[...slug]] and pass lang to source.getPage. Add locale-aware rewrite rule (/:lang/docs/:path*.mdx) and keep the bare /docs/ rewrite defaulting to en. https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm
Default to en so LLM consumers get a single-language document. Other locales available via /llms-full.txt?lang=zh etc. https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm
Summary
Implement comprehensive internationalization (i18n) support for the documentation site, adding support for English, Chinese (Simplified), Spanish, and Japanese languages. This includes language-specific documentation pages, middleware for language routing, and localized UI components.
Changes
index.{es,ja,zh}.mdx- Quick start guides in Spanish, Japanese, and Chineseapi.{es,ja,zh}.mdx- API reference pages in Spanish, Japanese, and Chinesetest.{es,ja,zh}.mdx- Component showcase pages in Spanish, Japanese, and Chinese/[lang]/docs,/[lang]/)layout.shared.tsx) for consistent branding across languagescn.ts)Testing
make test)make ci)Related Issues
Closes #
https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm