Skip to content

Add i18n support with English, Chinese, Spanish, and Japanese#112

Merged
Miyamura80 merged 7 commits into
mainfrom
claude/add-i18n-support-tj6aV
Feb 16, 2026
Merged

Add i18n support with English, Chinese, Spanish, and Japanese#112
Miyamura80 merged 7 commits into
mainfrom
claude/add-i18n-support-tj6aV

Conversation

@Miyamura80
Copy link
Copy Markdown
Owner

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

  • Added i18n configuration with support for 4 languages (en, zh, es, ja)
  • Created language-specific documentation pages:
    • index.{es,ja,zh}.mdx - Quick start guides in Spanish, Japanese, and Chinese
    • api.{es,ja,zh}.mdx - API reference pages in Spanish, Japanese, and Chinese
    • test.{es,ja,zh}.mdx - Component showcase pages in Spanish, Japanese, and Chinese
  • Implemented i18n middleware for automatic language routing based on URL parameters
  • Restructured app routing to support language-prefixed routes (/[lang]/docs, /[lang]/)
  • Added language-specific layout components with localized UI strings (table of contents, search, navigation labels, etc.)
  • Created shared layout utilities (layout.shared.tsx) for consistent branding across languages
  • Updated source loader to support language-aware page retrieval
  • Enhanced search API with locale-specific configuration for Chinese and Japanese (zero threshold/tolerance for better CJK support)
  • Refactored root layout to be language-agnostic and delegate to language-specific layouts
  • Added utility functions for className merging (cn.ts)

Testing

  • Tests pass (make test)
  • Linting passes (make ci)

Related Issues

Closes #

https://claude.ai/code/session_01UwMuBPaeouJ16zJTVa8UJm

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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 16, 2026

Greptile Summary

This 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 (/[lang]/docs), adds middleware for automatic language detection, and creates locale-specific content files.

Key changes:

  • Added i18n configuration with 4 language support (en, zh, es, ja)
  • Restructured app routing from /docs to /[lang]/docs with language-specific layouts
  • Implemented locale-aware middleware with proper static file exclusions
  • Updated API endpoints (/llms-full.txt, /api/search, /llms.mdx) to handle multiple locales
  • Enhanced search with CJK-optimized settings (zero threshold/tolerance for Chinese and Japanese)
  • Created translated content files for quick start, API reference, and component showcase pages
  • Updated Next.js rewrite rules to support both locale-prefixed and non-prefixed MDX routes

Previously identified issues:

  • Spanish translations missing diacritics (accent marks) throughout - already flagged in previous comments
  • These translation quality issues should be addressed but don't affect functionality

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

  • Safe to merge with minor translation quality improvements recommended
  • The i18n implementation is technically solid with proper routing, middleware, and API endpoint handling. The only issues are translation quality (Spanish diacritics) which were already identified in previous review threads and don't affect functionality. All locale-aware endpoints are correctly implemented and the rewrite rules properly handle both prefixed and non-prefixed routes.
  • Spanish content files (docs/content/docs/*.es.mdx) and Spanish UI strings (docs/app/[lang]/layout.tsx) need diacritic corrections for professional quality, but these are cosmetic fixes

Important Files Changed

Filename Overview
docs/lib/i18n.ts Defines i18n configuration with 4 supported languages (en, zh, es, ja)
docs/middleware.ts Implements i18n middleware for language routing with proper static file exclusions
docs/lib/source.ts Configures loader with i18n support, includes helper functions for OG images and LLM text generation
docs/next.config.mjs Updated rewrite rules to handle both locale-prefixed and non-prefixed MDX routes
docs/app/[lang]/layout.tsx Language-specific root layout with UI translations (Spanish translations already flagged as missing diacritics)
docs/app/[lang]/docs/[[...slug]]/page.tsx Docs page component with locale-aware routing and proper MDX rendering
docs/app/llms-full.txt/route.ts Full LLM text endpoint now properly filters by ?lang= query parameter
docs/app/api/search/route.ts Search API with locale-specific configuration for CJK languages (zero threshold/tolerance)

Last reviewed commit: 10fd972

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

27 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread docs/app/[lang]/layout.tsx Outdated
Comment thread docs/lib/layout.shared.tsx Outdated
Miyamura80 and others added 2 commits February 16, 2026 14:08
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>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

27 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread docs/app/[lang]/(home)/page.tsx Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 16, 2026

Additional Comments (1)

docs/app/og/docs/[...slug]/route.tsx
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.

Prompt To Fix With AI
This 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.

Miyamura80 and others added 2 commits February 16, 2026 14:17
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
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

28 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread docs/app/[lang]/docs/[[...slug]]/page.tsx
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
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

31 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread docs/lib/source.ts
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
@Miyamura80 Miyamura80 merged commit 7819b5c into main Feb 16, 2026
13 checks passed
@github-actions github-actions Bot deleted the claude/add-i18n-support-tj6aV branch February 16, 2026 15:22
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