-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a949426
commit 0720150
Showing
8 changed files
with
113 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { getRequestConfig } from 'next-intl/server'; | ||
import { routing } from './routing'; | ||
|
||
export default getRequestConfig(async ({ requestLocale }) => { | ||
// This typically corresponds to the `[locale]` segment | ||
let locale = await requestLocale; | ||
|
||
// Ensure that the incoming locale is valid | ||
if (!locale || !routing.locales.includes(locale as any)) { | ||
locale = routing.defaultLocale; | ||
} | ||
|
||
return { | ||
locale, | ||
messages: (await import(`../../messages/${locale}.json`)).default | ||
}; | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {defineRouting} from 'next-intl/routing'; | ||
|
||
export const routing = defineRouting({ | ||
// A list of all locales that are supported | ||
locales: ['en-US', 'zh-CN'], | ||
// Used when no locale matches | ||
defaultLocale: 'en-US', | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import createMiddleware from 'next-intl/middleware'; | ||
|
||
export default createMiddleware({ | ||
// A list of all locales that are supported | ||
locales: ['en-US', 'zh-CN'], | ||
// Used when no locale matches | ||
defaultLocale: 'en-US' | ||
}); | ||
|
||
import {routing} from './i18n/routing'; | ||
|
||
export const config = { | ||
// Match only internationalized pathnames | ||
matcher: ['/', '/(de|en)/:path*'] | ||
}; | ||
|
||
export default createMiddleware(routing); |
Oops, something went wrong.