Skip to content

Commit

Permalink
[app i18n]: warn about i18n configuration deprecation in app router
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Feb 21, 2025
1 parent bb8439b commit 08b86be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { transpileConfig } from '../build/next-config-ts/transpile-config'
import { dset } from '../shared/lib/dset'
import { normalizeZodErrors } from '../shared/lib/zod'
import { HTML_LIMITED_BOT_UA_RE_STRING } from '../shared/lib/router/utils/is-bot'
import { findDir } from '../lib/find-pages-dir'

export { normalizeConfig } from './config-shared'
export type { DomainLocale, NextConfig } from './config-shared'
Expand Down Expand Up @@ -679,6 +680,17 @@ function assignDefaults(
setHttpClientAndAgentOptions(result || defaultConfig)

if (result.i18n) {
const hasAppDir = Boolean(findDir(dir, 'app'))

if (hasAppDir) {
warnOptionHasBeenDeprecated(
result,
'i18n',
`i18n configuration in ${configFileName} is unsupported in App Router.\nLearn more about internationalization in App Router: https://nextjs.org/docs/app/building-your-application/routing/internationalization`,
silent
)
}

const { i18n } = result
const i18nType = typeof i18n

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/app-dir/i18n-hybrid/i18n-hybrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ describe('i18n-hybrid', () => {
files: __dirname,
})

it('should warn about i18n in app dir', async () => {
expect(next.cliOutput).toContain(
'i18n configuration in next.config.js is unsupported in App Router.'
)
})

it.each(urls.filter((url) => !url.expected))(
'does not resolve $pathname',
async (url) => {
Expand Down

0 comments on commit 08b86be

Please sign in to comment.