Skip to content

configure next-intl i18n for 5 languages#392

Merged
JeremyDev87 merged 3 commits intomasterfrom
feat/313-configure-next-intl-i18n
Feb 15, 2026
Merged

configure next-intl i18n for 5 languages#392
JeremyDev87 merged 3 commits intomasterfrom
feat/313-configure-next-intl-i18n

Conversation

@JeremyDev87
Copy link
Owner

Summary

  • Configure next-intl v4 with App Router pattern for internationalization support
  • Add 5 language support: English, Korean, Chinese (Simplified), Japanese, Spanish
  • Integrate i18n routing, middleware, message files, and NextIntlClientProvider into existing locale layout
  • Refactor lib/locale.ts to derive from next-intl routing config as single source of truth
  • Tighten CSP script-src policy for production (remove unsafe-eval/unsafe-inline)

Architecture

middleware.ts (locale detection/redirect)
    ↓
i18n/routing.ts (defineRouting - source of truth)
    ↓                    ↓
lib/locale.ts         i18n/request.ts (getRequestConfig)
(re-export)               ↓
                    messages/{locale}.json
                         ↓
              [locale]/layout.tsx
              (NextIntlClientProvider)
                    ↓
              widgets/components (useTranslations)

Changes

New files

File Description
i18n/routing.ts Routing config with 5 locales, always prefix, en default
i18n/request.ts Server request config with hasLocale validation and fallback
middleware.ts next-intl middleware for locale detection and routing
messages/{en,ko,zh-CN,ja,es}.json Translation files for hero, agents, codeExample, quickStart, faq sections
__tests__/i18n/routing.test.ts Routing config tests
__tests__/i18n/messages.test.ts Message key structure consistency tests
__tests__/i18n/request.test.ts Request config logic + path traversal security tests
__tests__/i18n/layout.test.ts generateStaticParams tests

Modified files

File Description
package.json Add next-intl@^4.8.2 dependency
next.config.ts Wrap with createNextIntlPlugin, tighten CSP for production
lib/locale.ts Derive SUPPORTED_LOCALES and DEFAULT_LOCALE from routing
__tests__/lib/locale.test.ts Update tests for 5 locales, add case-sensitivity checks
src/app/[locale]/layout.tsx Wrap with NextIntlClientProvider, call getMessages()

Test plan

  • yarn workspace landing-page vitest run — all i18n and locale tests pass
  • yarn workspace landing-page typecheck — no type errors
  • Verify all 5 message files have identical key structure (covered by messages.test.ts)
  • Verify hasLocale rejects path traversal attempts (covered by request.test.ts)
  • Verify generateStaticParams produces entries for all 5 locales (covered by layout.test.ts)
  • Verify middleware routes / to /en and handles all locale prefixes

Closes #313

- Install next-intl@4 and integrate plugin in next.config.ts
- Add i18n routing config with en, ko, zh-CN, ja, es locales
- Add i18n request config with locale validation and fallback
- Create middleware for automatic locale detection and routing
- Add translation message files for all 5 languages
- Wrap locale layout with NextIntlClientProvider
- Refactor lib/locale.ts to derive from next-intl routing config
- Add tests for routing, messages, request logic, and layout params
- Tighten CSP script-src to remove unsafe-eval/inline in production

Closes #313
@JeremyDev87 JeremyDev87 self-assigned this Feb 15, 2026
- Add setRequestLocale() call to enable static rendering with next-intl
- Fix prettier formatting in locale test file
- Exclude layout files from coverage (require Next.js server context)
@JeremyDev87 JeremyDev87 changed the title feat(landing-page): configure next-intl i18n for 5 languages configure next-intl i18n for 5 languages Feb 15, 2026
@JeremyDev87 JeremyDev87 added the landing-page Landing page project tasks label Feb 15, 2026
@JeremyDev87 JeremyDev87 merged commit 2fb9de0 into master Feb 15, 2026
23 checks passed
@JeremyDev87 JeremyDev87 deleted the feat/313-configure-next-intl-i18n branch February 15, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat landing-page Landing page project tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure next-intl i18n for 5 Languages

1 participant