-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Showing
4 changed files
with
16 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import en from './messages/en.json'; | ||
import {formats} from './src/i18n/request'; | ||
|
||
type Messages = typeof en; | ||
type Formats = typeof formats; | ||
|
||
declare global { | ||
// Use type safe message keys with `next-intl` | ||
interface IntlMessages extends Messages {} | ||
interface IntlFormats extends Formats {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import en from './messages/en.json'; | ||
import {formats} from './src/i18n/request'; | ||
|
||
type Messages = typeof en; | ||
type Formats = typeof formats; | ||
|
||
declare global { | ||
// Use type safe message keys with `next-intl` | ||
interface IntlMessages extends Messages {} | ||
interface IntlFormats extends Formats {} | ||
} |
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,40 +1,16 @@ | ||
import {notFound} from 'next/navigation'; | ||
import {Formats} from 'next-intl'; | ||
import {getRequestConfig} from 'next-intl/server'; | ||
import {routing} from './routing'; | ||
|
||
export const formats = { | ||
dateTime: { | ||
short: { | ||
day: 'numeric', | ||
month: 'short', | ||
year: 'numeric' | ||
} | ||
}, | ||
number: { | ||
precise: { | ||
maximumFractionDigits: 5 | ||
} | ||
}, | ||
list: { | ||
enumeration: { | ||
style: 'long', | ||
type: 'conjunction' | ||
} | ||
} | ||
} as const satisfies Partial<Formats>; | ||
|
||
export default getRequestConfig(async ({locale}) => { | ||
// Validate that the incoming `locale` parameter is valid | ||
if (!routing.locales.includes(locale as any)) notFound(); | ||
|
||
return { | ||
messages: ( | ||
await (locale === 'en' | ||
? // When using Turbopack, this will enable HMR for `en` | ||
import('../../messages/en.json') | ||
: import(`../../messages/${locale}.json`)) | ||
).default, | ||
formats | ||
).default | ||
}; | ||
}); |