-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n-next): use next-intl package instead of i18next
- Loading branch information
1 parent
995bb69
commit afbbd89
Showing
11 changed files
with
222 additions
and
205 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,6 +1,10 @@ | ||
import createNextIntlPlugin from "next-intl/plugin"; | ||
|
||
const withNextIntl = createNextIntlPlugin(); | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
transpilePackages: ["@refinedev/antd"], | ||
}; | ||
|
||
export default nextConfig; | ||
export default withNextIntl(nextConfig); |
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 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 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const I18N_COOKIE_NAME = "NEXT_LOCALE"; | ||
export const DEFAULT_LOCALE = "en"; |
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,13 @@ | ||
"use server"; | ||
|
||
import { cookies } from "next/headers"; | ||
import { DEFAULT_LOCALE } from "./config"; | ||
import { I18N_COOKIE_NAME } from "./config"; | ||
|
||
export async function getUserLocale() { | ||
return cookies().get(I18N_COOKIE_NAME)?.value || DEFAULT_LOCALE; | ||
} | ||
|
||
export async function setUserLocale(locale: string) { | ||
cookies().set(I18N_COOKIE_NAME, locale); | ||
} |
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,14 @@ | ||
"use server"; | ||
|
||
import { getUserLocale } from "@i18n"; | ||
import { getRequestConfig } from "next-intl/server"; | ||
|
||
export default getRequestConfig(async () => { | ||
const locale = await getUserLocale(); | ||
|
||
return { | ||
locale, | ||
messages: (await import(`../../public/locales/${locale}/common.json`)) | ||
.default, | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.