configure next-intl i18n for 5 languages#392
Merged
JeremyDev87 merged 3 commits intomasterfrom Feb 15, 2026
Merged
Conversation
- 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
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NextIntlClientProviderinto existing locale layoutlib/locale.tsto derive fromnext-intlrouting config as single source of truthscript-srcpolicy for production (removeunsafe-eval/unsafe-inline)Architecture
Changes
New files
i18n/routing.tsalwaysprefix,endefaulti18n/request.tshasLocalevalidation and fallbackmiddleware.tsmessages/{en,ko,zh-CN,ja,es}.json__tests__/i18n/routing.test.ts__tests__/i18n/messages.test.ts__tests__/i18n/request.test.ts__tests__/i18n/layout.test.tsgenerateStaticParamstestsModified files
package.jsonnext-intl@^4.8.2dependencynext.config.tscreateNextIntlPlugin, tighten CSP for productionlib/locale.tsSUPPORTED_LOCALESandDEFAULT_LOCALEfromrouting__tests__/lib/locale.test.tssrc/app/[locale]/layout.tsxNextIntlClientProvider, callgetMessages()Test plan
yarn workspace landing-page vitest run— all i18n and locale tests passyarn workspace landing-page typecheck— no type errorsmessages.test.ts)hasLocalerejects path traversal attempts (covered byrequest.test.ts)generateStaticParamsproduces entries for all 5 locales (covered bylayout.test.ts)/to/enand handles all locale prefixesCloses #313