ืฉืืื ืืช ืฉืืืชืื ืืงืืื ืกืืืื ืฉื ืืืกืื ืขื ืืื ืืคื ืื ืืืฃ ืืื ืืืกืคืง ื-AI ืฉืชืืืจื
ืืืกืืืจืืืช ืืจืกืืืช
- "ืืืกืืืจืื ืจืืฉืื ืืช"v9.8.423.11.2026
ืืชืืื ืฉื ืืืฃ ืืื ืชืืจืื ืืืืฆืขืืช AI.
ืฆืคืืื ืืืจืกื ืืืืจืื ื ืฉื ืืชืืื ืืืงืืจื ืืื ืืืืชืื ืืฉ ืืื ืจืขืืื ืืฉืืคืืจ ืืชืืขืื ืืื, ืื ืชืืกืกื ืืชืจืื ืขื ืืื ืืืฉืช Pull Request ื-GitHub.
ืงืืฉืืจ GitHub ืืชืืขืืืืขืชืงืช ื-Markdown ืฉื ืืืกืื ืืืื
ืชืจืืื ืืช ืืชืจ ื-vinext ืฉืืื ืืืืฆืขืืช Intlayer
vinext ืืืืฉ ืืืืฉ ืืช ื-API ืฉื Next.js ืืขื Vite. ืชืืงืืืช app/, ืืืืืื next/* ืืืงืืืฅ proxy.ts ืืืฉืืืื ืืขืืื, ืืื ืืื ืืื ืจืฆื ืืจื Vite ืืื ืืจื Turbopack ืื webpack.
Intlayer ืืฉืชืื ืืืืืจื ืืื ืืฉืชื ืืืืืืช: next-intlayer ืขืืืจ ื-hooks, ื-providers ืื-proxy ืฉืืงืืืคืื ื ืืืช ืฉืืื ืืืจ ืืฉืชืืฉืืช ืืื ื-Next.js, ื-vite-intlayer ืขืืืจ ืฆื ืืื ืืื (ืงืืืคืืืฆืื ืฉื ืืืืื ืื, ืืขืงื ืืืืคืืืืืืฆืื ืฉื ื-bundle).
ืืจืืฆืื Next.js ืขื ื-toolchain ืฉืื? ืขืงืื ืืืงืื ืืืช ืืืจื ืืืืจืื ื-Next.js 16.
ืชืืื ืขื ืืื ืื
ืืื Intlayer ืืื ืืืืคืืช ืืืจืืช?
ืืืฉืืืื ืืคืชืจืื ืืช ืืื next-intl ืื i18next, Intlayer ืืืืข ืขื ืืืคืืืืืืฆืืืช ืืืื ืืช:
ืืืชื ืงืื next-intlayer ืจืฅ ื-Next.js ืื-vinext. Server Components ืืคืขื ืืื ืชืืื ืืฉืจืช, Client Components ืงืืจืืื ืืืชื ืืจื ื-provider, ืื ืืชืื ืืฉืคืืช ืจืฅ ืืชืื proxy.ts ืฉืืื. ืืขืืจ ืืื ืฉื ื ื-toolchains ืื ื ืืืข ืืงืืืคืื ื ืืืช ืฉืืื.
ืืืงืื ืืืขืื ืงืืฆื JSON ืขื ืงืืื ืืืคืื ืฉืืื, ืืืขื ืื ืจืง ืืช ืืชืืื ืื ืืจืฉ. ืชืืกืฃ ื-Vite ืืืืืฃ ืื ืงืจืืื ื-useIntlayer ืืขืจืืื ืฉืืงืืืคืื ื ืื ืืืืช ืืฉืชืืฉืช ืืื, ืืื ืืงืืื ืืช ืืืื ื-bundle ืืืืคืื ืืขื 50%.
ืืืืงืช ืืชืืื ืืคื ืงืืืคืื ื ืื ืืคืฉืืช ืืช ืืชืืืืงื ืฉื ืืคืืืงืฆืืืช ืืืืืืช. ืืคืฉืจ ืืฉืืคื ืื ืืืืืง ืชืืงืืืช ืคืืฆ'ืจ ืืื ืืขืืืจ ืขื ืื ืืกืืก ืืงืื ืฉื ืืชืืื, ื-Intlayer ืืืงืื ืืืืืื ืืื ืืฉืืืจ ืขื ืืืืง ืืชืืื.
ืฉืืืจืช ืืชืืื ืืื ืืงืืืคืื ื ืื ืืงืืื ื ืืช ืืืงืฉืจ ืื ืืจืฉ ื-LLMs. Intlayer ืืืืข ืขื CLI ืืืืืงืช ืชืจืืืืื ืืกืจืื, LSP, ืฉืจืช MCP ื-agent skills.
ืชืจืืื ืืฆืื ืืจ ื-CI/CD ืฉืืื ืขื ื-LLM ืืคื ืืืืจืชืื, ืขื ืืฉืืื ืกืคืง ื-AI ืฉืืื. Intlayer ืืฆืืข ืื ืงืืืคืืืืจ ืืืืืืืฆืื ืฉื ืืืืืฅ ืชืืื, ืืคืืืคืืจืืช ืืื ืืชืจืืื ืืจืงืข.
Intlayer ืืกืคืง ืขืืจื ืืืืืืื ืืืืจืื ืขืฆืื ื-CMS ืืื ืื ืืืื ืชืืื ืจื-ืืฉืื ื ืืืื ืืืช ืขื ืืชืจืืืื ืืงืืคืืจืืืืจืื. ืืคืฉืจ ืืืืกื ืืช ืืชืืื ืืงืืืืช ื/ืื ืืจืืืง.
ืืืจืื ืฉืื ืืืจ ืฉืื ืืืืืจืช Intlayer ืืืคืืืงืฆืืืช vinext
ืืชืงื ืช ืืชืืืืืช
ืืชืืืื ืืคืจืืืงื vinext ืฉืขืืื. ืืื ืืืฆืืจ ืืื, ืืจืืฆื
npm create vinext-app@latest. ืืื ืืืขืืืจ ืืคืืืงืฆืืืช Next.js ืงืืืืช, ืืจืืฆืnpx vinext init.ืืืืจ ืืื ืืชืงืื ื ืืช Intlayer:
bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
intlayer
ืืืืืื ืืืจืืืืช ืฉืืกืคืงืช ืืช ืืื ืืืื ืืื: ื ืืืื ืชืฆืืจื, ืชืจืืื, ืืฆืืจืช ืชืืื, ืืจื ืกืคืืืฆืื ืืคืงืืืืช CLI.
next-intlayer
ืืกืคืง ืืช ื-providers, ื-hooks ืื-proxy ืขืืืจ ื-API ืฉื Next.js. vinext ืืคื ื ืืช
next/navigation,next/headersื-next/serverืืืืืืฉืื ืืฉืื, ืืืืnext-intlayerืขืืื ืืื ืฉืื ืื.vite-intlayer
ืชืืกืฃ ื-Vite ืฉืืื ื ืืช ืืฆืืจืืช ืืชืืื ืฉืืื, ืขืืงื ืืืจืืื ืืคืืชืื ืืืืฆืข ืืืคืืืืืืฆืื ืืืืืื ืื ื-bundle ืฉื ืืคืจืืืงืฉื. ืืื ืืืืืฃ ืืช ืชืืกืฃ Next.js ืืฉื
withIntlayer(), ืฉ-vinext ืืื ื ืืจืืฅ.
ืืืืจืช ืืคืจืืืงื
ืืืจื ืื ืืืคืืืงืฆืื ืชืฉืชืืฉ ืื ืชืืื URL ืืชืืจืืืื (ืืืฉื
/en/about,/fr/about) ืื ืชืืืฉ ืชืืื ืืื ืืงืืข ืฉืคื ืื ืชืื (ืืืฉื/about, ืืฉืืฉืคื ืืืืื ืืคื cookies, ืืืชืจืืช ืื ืคืจืืืจื ืฉืืืืชื).ืืจืืืืงืืืจื
ืื ืืืคืื ืืืชืืจืืืื ืืงืื ื ืื ืชืืช ืืืงืืข ืืืื ืื
[locale]. ืื ืืืืืฅ ื-SEO ืืืจืื ืืืจ ืกืืื, ืืฉืื ืฉืืื ืฉืคื ืืฉ ืืชืืืช URL ืืฉืื:bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืชืฆืืจื
ืฆืจื ืงืืืฅ
intlayer.config.tsืืื ืืืฆืืืจ ืขื ืืฉืคืืช ืื ืชืืืืช:intlayer.config.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { Locales, type IntlayerConfig } from "intlayer"; const config: IntlayerConfig = { internationalization: { locales: [ Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH, // Your other locales ], defaultLocale: Locales.ENGLISH, }, routing: { mode: "prefix-no-default", // or `prefix-all` }, }; export default config;ืืจืืืืงืืืจื
ืื ืชืืืื ืืื ื ืืืืืื ืืงืืข
[locale]. ืื ืืืคืื ื ืืฆืืื ืืฉืืจืืช ืชืืชsrc/app/, ืืืฉืคื ืืืืขื ื-cookies, ืืืืชืจืืช ืื ืืคืจืืืจื ืฉืืืืชื. ืื ืืชืืื ืืืืืืช ืืงืจื ืืืืคืืืงืฆืืืช ืขื ืืืืืช:bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืชืฆืืจื
ืืืืืจื ืืช
routing.modeื-"search-params"(ืืืฉื/about?locale=fr) ืื ื-"no-prefix":intlayer.config.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { Locales, type IntlayerConfig } from "intlayer"; const config: IntlayerConfig = { internationalization: { locales: [ Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH, // Your other locales ], defaultLocale: Locales.ENGLISH, }, routing: { mode: "search-params", // or `no-prefix` }, }; export default config;ืืงืืืฅ ืืื ืงืืืข ืื ืืช ืืคื ืืืช ื-proxy, ืฉืืืช ื-cookies, ืืืืงืื ืืืกืืืืช ืฉื ืืฆืืจืืช ืืชืืื, ืืืืื ืืขืื. ืจืื ืืช ืชืืขืื ืืชืฆืืจื ืืจืฉืืื ืืืืื.
ืฉืืืื Intlayer ืืชืฆืืจืช Vite ืฉืืื
ืืืกืืคื ืืช ืืชืืกืฃ
intlayer()ืืืvinext()ืืงืืืฅvite.config.ts:vite.config.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { defineConfig } from "vite"; import vinext from "vinext"; import { intlayer } from "vite-intlayer"; export default defineConfig({ plugins: [ vinext(), intlayer({ // Locale routing is handled by `src/proxy.ts` (step 7) proxy: { ignore: () => true }, }), ], });ืืชืืกืฃ
intlayer()ืืื ื ืืช ืืืืืื ืื ืฉืืื ืืคื ื ืชืืืืช ืืื ืืื, ืขืืงื ืืืจื ืงืืฆื ืืชืืื ืืคืืชืื, ืืืืืืจ ืืช ื-aliases ืืืืืคืืืืืืฆืืืช ืฉ-next-intlayerืืฉืชืืฉ ืืื ืืกืืืืืช RSC, SSR ืืืืงืื.intlayer()ืืืืข ืื ืขื middleware ืื ืืชืื ืฉืคืืช ืขืืืจ ืฉืจืช ืืคืืชืื ืฉื Vite. ื-vinext, ืืงืืืฅsrc/proxy.tsืืืจ ืขืืฉื ืืช ืืขืืืื ืืื, ืืคืืชืื ืื-runtime ืฉื ืืคืจืืืงืฉื, ืืืื ืืืคืฉืจืืชignoreืืืื ืืช ืื ืฉื Vite ืืื ืื ืื ืชื ืื ืืงืฉื ืคืขืืืื.ืื ืชืฉืชืืฉื ื-
withIntlayer()ืืงืืืฅnext.config.ts. vinext ืงืืจื ืืชnext.config.tsืขืืืจ ืืคืฉืจืืืืช ืืืredirects,rewritesื-headers, ืื ืืื ื ืืจืืฅ ืชืืกืคื webpack ืื Turbopack.ืื ืืชื ืคืืจืกืื ื-Cloudflare Workers, ืฉืืจื ืขื ืืชืืกืฃ
cloudflare()ืฉ-vinext initืืฆืจ:vite.config.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { cloudflare } from "@cloudflare/vite-plugin"; import { defineConfig } from "vite"; import vinext from "vinext"; import { intlayer } from "vite-intlayer"; export default defineConfig({ plugins: [ vinext(), intlayer({ proxy: { ignore: () => true } }), cloudflare({ viteEnvironment: { name: "rsc", childEnvironments: ["ssr"] }, }), ], });ืืืืจืช ื ืชืืื ืฉืคื ืืื ืืืื
ืืกืืจื ืืช ืื ืืชืืื ื-
RootLayoutืืืืืืคื ืืืชื ืืงืื ืืื:src/app/layout.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import type { PropsWithChildren, FC } from "react"; import "./globals.css"; const RootLayout: FC<PropsWithChildren> = ({ children }) => ( // You can still wrap the children with other providers, like `next-themes` or `react-query` <>{children}</> ); export default RootLayout;ืืฉืืจืช
RootLayoutืจืืง ืืืคืฉืจืช ื-layout ืฉื ืืฉืคื ืืืืืืจ ืืช ืืชืืื ืืชlangื-dirืขื ืืชื<html>.ืืืกืืคื layout ืืชืืงืืืช
[locale]ืฉืืื:src/app/[locale]/layout.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { getHTMLTextDir } from "intlayer"; import type { NextLayoutIntlayer } from "next-intlayer"; import { IntlayerProvider } from "next-intlayer/server"; export { generateStaticParams } from "next-intlayer"; const LocaleLayout: NextLayoutIntlayer = async ({ children, params }) => { const { locale } = await params; return ( <html lang={locale} dir={getHTMLTextDir(locale)}> <body> <IntlayerProvider locale={locale}>{children}</IntlayerProvider> </body> </html> ); }; export default LocaleLayout;IntlayerProviderืืื ืืืกื ืืช ืฉื ื ืืฆืื ืืขืฅ: ืืื ืืกืคืง ืืช ืืฉืคื ื-Server Components ืืืจืืื ืืช ื-provider ืฉื ืืืงืื ืื ืฉ-Client Components ืืงืืืื ืืช ืืืชื ืฉืคื.ืืืงืืข
[locale]ืืืืืง ืืช ืืฉืคื:/en-US/aboutืืคืืขื ื ื-en-US, ื-/fr/aboutื-fr. ืืงืืืฅ ืืงืืืsrc/app/page.tsxืืืจ ืืื ื ืืฉืืืืฉ ืื ืืชื ืืืกืืจื. ื-proxy (ืฉืื 7) ืืืืฉ ืืช ืฉืคืช ืืจืืจืช ืืืืื ืืฉืืจืฉ.generateStaticParamsืืืจื ื-vinext ืืืฆืข prerender ืืื ืืฃ ืขืืืจ ืื ืฉืคื. vinext ืื ืืืืฃ ืืชdynamicParams, ืืืื ืฉืคื ืื ืืืืจืช ืืืืืจื 404 ืืฉืืืืืจืืexport const dynamicParams = false.ืืื ืชืืงืืืช
[locale]. ืืืืืจื ืืชsrc/app/layout.tsxืื ืฉืืงืจื ืืช ืืฉืคื ืืืืงืฉื ืืืขืืืฃ ืืช ืืืคืืืงืฆืื ื-IntlayerProvider:src/app/layout.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import type { Metadata } from "next"; import type { ReactNode } from "react"; import "./globals.css"; import { getHTMLTextDir, getIntlayer } from "intlayer"; import { getLocale, IntlayerProvider } from "next-intlayer/server"; export const generateMetadata = async (): Promise<Metadata> => { const locale = await getLocale(); const { title, description, keywords } = getIntlayer("metadata", locale); return { title, description, keywords, }; }; const RootLayout = async ({ children, }: Readonly<{ children: ReactNode; }>) => { const locale = await getLocale(); return ( <html lang={locale} dir={getHTMLTextDir(locale)}> <body> <IntlayerProvider locale={locale}>{children}</IntlayerProvider> </body> </html> ); }; export default RootLayout;ืืฆืืจื ืขื ืืชืืื ืฉืืื
ืฆืจื ืืฆืืจืืช ืชืืื ืืื ืืืืกื ืืช ืืชืจืืืืื:
src/app/[locale]/page.content.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { t, type Dictionary } from "intlayer"; const pageContent = { key: "page", content: { getStarted: { main: t({ "he-IL": "ืืชืืืื ืืขืจืืื ืฉื", en: "Get started by editing", fr: "Commencez par รฉditer", es: "Comience por editar", }), pageLink: "src/app/page.tsx", }, }, } satisfies Dictionary; export default pageContent;ืืฆืืจืืช ืชืืื ืืืืืืช ืืืืืฆื ืืื ืืงืื ืืชืื ืืชืืงืืื
contentDir(ืืืจืืจืช ืืืื./src), ืื ืขืื ืื ืชืืืืืช ืืกืืืืช ืฉื ืืฆืืจืืช ืชืืื (ืืืจืืจืช ืืืื.content.{json,ts,tsx,js,jsx,mjs,cjs,md,mdx,yaml,yml}).ืืคืจืืื ื ืืกืคืื ืจืื ืืช ืชืืขืื ืืฆืืจืช ืืชืืื.
ืฉืืืืฉ ืืชืืื ืืงืื ืฉืืื
ืืฉื ืืืืืื ืื ืฉืืื ืืื ืงืืืคืื ื ืื:
src/app/[locale]/page.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import type { FC } from "react"; import { ClientComponentExample } from "@components/ClientComponentExample"; import { ServerComponentExample } from "@components/ServerComponentExample"; import { type NextPageIntlayer, useIntlayer } from "next-intlayer"; const PageContent: FC = () => { const content = useIntlayer("page"); return ( <> <p>{content.getStarted.main}</p> <code>{content.getStarted.pageLink}</code> </> ); }; const Page: NextPageIntlayer = () => ( <> <PageContent /> <ServerComponentExample /> <ClientComponentExample /> </> ); export default Page;src/components/ClientComponentExample.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
"use client"; import type { FC } from "react"; import { useIntlayer } from "next-intlayer"; export const ClientComponentExample: FC = () => { const content = useIntlayer("client-component-example"); // Create related content declaration return ( <div> <h2>{content.title}</h2> <p>{content.content}</p> </div> ); };src/components/ServerComponentExample.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import type { FC } from "react"; import { useIntlayer } from "next-intlayer"; export const ServerComponentExample: FC = () => { const content = useIntlayer("server-component-example"); // Create related content declaration return ( <div> <h2>{content.title}</h2> <p>{content.content}</p> </div> ); };next-intlayerืืื ืืืืืืืจืคื: ืชื ืื ืืืืฆืืreact-server, ืฉ-vinext ืืืื ืขื ืกืืืืช ื-RSC ืฉืื, ื ืืชื ื-Server Components ืืช ืืืืืืฉ ืฉื ืืฉืจืช, ืืขืื Client Components ืืงืืืื ืืช ืืืืืืฉ ืืืืกืก ื-context. ืืืชื ืงืจืืื ืขืืืืช ืืฉื ื ืืฆืืืื.ืืื ืืืฉืชืืฉ ืืชืืื ืืชืืื ื ืืกืื
string, ืืืalt,title,hrefืืaria-label, ืงืจืื ืืช ืืขืจื ืฉืื:tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืืืืืข ื ืืกืฃ ืจืื ืืช ืชืืขืื
useIntlayer.ืื ืืืคืืืงืฆืื ืฉืืื ืืืจ ืงืืืืช, ืืงืืืคืืืืจ ืฉื Intlayer ืืคืงืืืช extract ืืืคืืื ืืืคื ืงืืืคืื ื ืืืช ืืฉื ืืื.
ืืืืจืช ื-proxy ืืืืืื ืฉืคื
vinext ืืจืืฅ ืืช
proxy.ts(ืืืชmiddleware.ts) ืืื Next.js 16, ืืคืืชืื ืืืคืจืืืงืฉื, ืืืื ื-Cloudflare Workers. ืืืฆืื ืืช ื-proxy ืฉื Intlayer:src/proxy.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
export { intlayerProxy as proxy } from "next-intlayer/proxy"; export const config = { matcher: "/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)", };intlayerProxyืืืื ืืช ืืฉืคื ืืืืขืืคืช ืฉื ืืืฉืชืืฉ, ืืคื ื ืืืชืืืช ืืืชืืืื ืืคื ืืชืฆืืจื ืืฉืืืจ ืืช ืืฉืคื ื-cookie. ืืื ืื ืืขืืืจ ืืช ืืฉืคื ื-getLocale()ืื-hooks ืฉื ืืฉืจืช, ืืืื ืฉืืจื ืืืชื ืื ืืืจืืืืงืืืจื ืืื ื ืชืื ืฉืคื.ืืื ืืฉืจืฉืจ ืืื proxies (ืืืฉื
intlayerProxyืขื ืืืืืช), ืืฉืชืืฉื ื-multipleProxies:tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืืื ืืื ืืืื-ืืืื ืฉืืื
ืืืคืฆืืื ืืvinext ืชืืื ื-Metadata API. ืืฉืชืืฉื ื-
generateMetadataืืื ืขืgetIntlayerืืื ืืชืจืื ืืช ืืืื-ืืืื ืฉื ืืืคืื:src/app/[locale]/metadata.content.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { type Dictionary, t } from "intlayer"; import type { Metadata } from "next"; const metadataContent = { key: "page-metadata", content: { title: t({ "he-IL": "ืืคืืืงืฆืืืช ื-vinext ืฉืื", en: "My vinext app", fr: "Mon application vinext", es: "Mi aplicaciรณn vinext", }), description: t({ "he-IL": "ืืคืืืงืฆืืืช Next.js ืฉืจืฆื ืขื Vite", en: "A Next.js app running on Vite", fr: "Une application Next.js qui tourne sur Vite", es: "Una aplicaciรณn Next.js que funciona con Vite", }), }, } satisfies Dictionary<Metadata>; export default metadataContent;src/app/[locale]/layout.tsx or src/app/[locale]/page.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { getIntlayer, getMultilingualUrls } from "intlayer"; import type { Metadata } from "next"; import type { LocalPromiseParams } from "next-intlayer"; export const generateMetadata = async ({ params, }: LocalPromiseParams): Promise<Metadata> => { const { locale } = await params; const metadata = getIntlayer("page-metadata", locale); /** * Generates an object containing all url for each locale. * * Example: * ```ts * getMultilingualUrls('/about'); * * // Returns * // { * // en: '/about', * // fr: '/fr/about', * // es: '/es/about', * // } * ``` */ const multilingualUrls = getMultilingualUrls("/"); const localizedUrl = multilingualUrls[locale as keyof typeof multilingualUrls]; return { ...metadata, alternates: { canonical: localizedUrl, languages: { ...multilingualUrls, "x-default": "/" }, }, openGraph: { url: localizedUrl, }, }; }; // ... Rest of the codeืืคืื ืงืฆืื
getIntlayerืืืืืืืช ื-intlayerืืืืืจื ืขืจืืื ืืืืืืื, ืืืื ืื ืืืืืืืงื ืืืื-ืืืื. ืื ืฉืnext-intlayerืขืืืคืช ืืืชื ืขืืืจ ืืขืืจื ืืืืืืืืื.ืืื ืืื ื-sitemap.xml ืื-robots.txt ืฉืืื
ืืืคืฆืืื ืืsitemap.tsื-robots.tsืขืืืืื ืืื ื-Next.js. ืืฉืชืืฉื ื-getMultilingualUrlsืืื ืืจืฉืื ืื ืืชืืืช URL ืืชืืจืืืช:src/app/sitemap.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { getMultilingualUrls } from "intlayer"; import type { MetadataRoute } from "next"; const sitemap = (): MetadataRoute.Sitemap => [ { url: "https://example.com", alternates: { languages: { ...getMultilingualUrls("https://example.com"), "x-default": "https://example.com", }, }, }, { url: "https://example.com/login", alternates: { languages: { ...getMultilingualUrls("https://example.com/login"), "x-default": "https://example.com/login", }, }, }, ]; export default sitemap;src/app/robots.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import type { MetadataRoute } from "next"; import { getMultilingualUrls } from "intlayer"; const getAllMultilingualUrls = (urls: string[]) => urls.flatMap((url) => Object.values(getMultilingualUrls(url)) as string[]); const robots = (): MetadataRoute.Robots => ({ rules: { userAgent: "*", allow: ["/"], disallow: getAllMultilingualUrls(["/login", "/register"]), }, host: "https://example.com", sitemap: `https://example.com/sitemap.xml`, }); export default robots;ืฉืื ืื ืฉืคืช ืืชืืื
ืืืคืฆืืื ืืืืฉืชืืฉื ื-
next/linkืืื ืื ืืื ืืืฃ ืืืชืืจืื. vinext ืฉืืืจ ืขื ื ืืืื ืืฆื ืืืงืื ืืขื prefetching, ืืืื ืืืขืืจ ืืชืืฆืข ืืื ืจืขื ืื ืืื:src/components/LocaleSwitcher.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
"use client"; import type { FC } from "react"; import { Locales, getHTMLTextDir, getLocaleName, getLocalizedUrl, } from "intlayer"; import { useLocale } from "next-intlayer"; import Link from "next/link"; export const LocaleSwitcher: FC = () => { const { locale, pathWithoutLocale, availableLocales, setLocale } = useLocale(); return ( <div> <button popoverTarget="localePopover">{getLocaleName(locale)}</button> <div id="localePopover" popover="auto"> {availableLocales.map((localeItem) => ( <Link href={getLocalizedUrl(pathWithoutLocale, localeItem)} key={localeItem} aria-current={locale === localeItem ? "page" : undefined} onClick={() => setLocale(localeItem)} replace // The browser "back" button returns to the previous page > <span> {/* Locale - e.g. FR */} {localeItem} </span> <span> {/* Language in its own Locale - e.g. Franรงais */} {getLocaleName(localeItem, locale)} </span> <span dir={getHTMLTextDir(localeItem)} lang={localeItem}> {/* Language in current Locale - e.g. Francรฉs with current locale set to Locales.SPANISH */} {getLocaleName(localeItem)} </span> <span dir="ltr" lang={Locales.ENGLISH}> {/* Language in English - e.g. French */} {getLocaleName(localeItem, Locales.ENGLISH)} </span> </Link> ))} </div> </div> ); };ืืคื ืืืช ืืชืืขืื:
ืืฆืืจืช ืงืืืคืื ื ืืช ืงืืฉืืจ ืืชืืจืืืช
ืืืคืฆืืื ืืืงืืืคืื ื ืืช
Linkืืืชืืืช ืืืฉืืช ืืืกืืคื ืืช ืืฉืคื ืื ืืืืืช ืืงืืืืืช ืืืชืืืืช URL ืคื ืืืืืช, ืื ืฉืืฉืชืืฉ ืฆืจืคืชื ืฉืืืืฅ ืขื/aboutืืืืข ื-/fr/about:src/components/Link.tsxืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
"use client"; import { getLocalizedUrl } from "intlayer"; import NextLink, { type LinkProps as NextLinkProps } from "next/link"; import { useLocale } from "next-intlayer"; import type { PropsWithChildren, FC } from "react"; /** * Checks whether a URL is external (starts with http:// or https://). */ export const checkIsExternalLink = (href?: string): boolean => /^https?:\/\//.test(href ?? ""); /** * Link that localizes internal URLs with the current locale. */ export const Link: FC<PropsWithChildren<NextLinkProps>> = ({ href, children, ...props }) => { const { locale } = useLocale(); const isExternalLink = checkIsExternalLink(href.toString()); const hrefI18n: NextLinkProps["href"] = href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href; return ( <NextLink href={hrefI18n} {...props}> {children} </NextLink> ); };ืงืืืช ืืฉืคื ืื ืืืืืช ื-Server Actions
ืืืคืฆืืื ืืืงืจืื ื-
getLocaleืืชืืnext-intlayer/serverืืชืื Server Action:src/app/actions/getLocale.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
getLocaleืงืืจื ืืช ืืฉืคื ืฉื-proxy ืืืืืจ ืืืืชืจืืช ืืืงืฉื, ืืืจ ืื ืืช ื-cookie ืฉื ืืฉืคื, ืืืจ ืื ืืช ืืืืชืจืชAccept-Languageืฉื ืืืคืืคื, ืืืืืจ ืืฉืคืช ืืจืืจืช ืืืืื.ืคืจืืกื ื-Cloudflare Workers
ืืืคืฆืืื ืืIntlayer ืืงืืคื ืืช ืืืืืื ืื ืืชืื ื-bundle ืืืื ืืื ืืื, ืืืื ืฉืื ืืืจ ืื ืงืืจื ืืช ืืขืจืืช ืืงืืฆืื ืืืื ืจืืฆื ืืืืคืืืงืฆืื ืจืฆื ืืื ืฉืืื ื-workerd. ืื ื ืืคืจืกื ืืืืฆืขืืช ื-CLI ืฉื vinext:
bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืืื ืืคืจืืก ืืืงืื ืืืจ (Vercel, Netlify, AWS, Node.js), ืืืกืืคื ืืช ืชืืกืฃ ื-Vite ืืฉื Nitro ืืื
vinext(), ืื ืืืืืจืoutput: "standalone"ื-next.config.ts. ืืืืืจื ืฉื Intlayer ืื ืืฉืชื ื.ืืืืืฅ ืืชืืื ืืืงืืืคืื ื ืืืช ืฉืืื
ืืืคืฆืืื ืืืืืกืืก ืงืื ืงืืื, Intlayer ืืกืคืง ืงืืืคืืืืจ ืืืืืฅ ืืืขืืจืช ืืืจืืืืช ืฉื ืืชืื ืืฉืืจืืช ืืงืื ืืืฆืืจืืช ืชืืื.
ืืคืขืืื ืืช ืืงืืืคืืืืจ ื-
intlayer.config.ts:intlayer.config.tsืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
import { type IntlayerConfig } from "intlayer"; const config: IntlayerConfig = { // ... Rest of your config compiler: { /** * Indicates if the compiler should be enabled. */ enabled: true, /** * Defines the output files path */ output: ({ fileName, extension }) => `./${fileName}${extension}`, /** * If `true`, the compiler rewrites the component files on disk. * If `false`, the transformation stays in the build output only. */ saveComponents: false, /** * Dictionary key prefix */ dictionaryKeyPrefix: "", }, }; export default config;ืืจืืฆื ืืช ืืืืืฅ ืืื ืืืืืจ ืืช ืืงืืืคืื ื ืืืช ืืืืืฅ ืืช ืืชืืื:
bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืชืืกืฃ ื-Vite โ
intlayer()ืืืื ืืช ืืงืืืคืืืืจ. ืืืืจ ืฉืืืืจืชื ืืชcompiler.enabled, ืืจืืฆื ืืช ืฉืจืช ืืคืืชืื ืื ืืช ืืื ืืื ืืจืืื:bashืืขืชืงืช ืงืืืืขืชืงืช ืืงืื ืืืื
ืืืืจืช TypeScript
Intlayer ืืฉืชืืฉ ื-module augmentation ืืื ืืืงืืื ืืช ืืคืชืืืช ืืชืืื ืืืขืจืืื ืฉืืื.


ืืืื ืืช ืืืืคืืกืื ืฉื ืืฆืจื ืืชืฆืืจืช ื-TypeScript ืฉืืื:
ืืขืชืงืช ืืงืื ืืืื
ืชืฆืืจืช Git
ืืชืขืืื ืืืงืืฆืื ืฉ-Intlayer ืืืืฆืจ:
ืืขืชืงืช ืืงืื ืืืื
ืชืืกืฃ VS Code
ืืชืงืื ื ืืช ืชืืกืฃ Intlayer ื-VS Code ืืจืฉืื ืืืฉืืื ืืืืืืืืช ืฉื ืืคืชืืืช, ืฉืืืืืช ืชืจืืื ืืกืจ, ืชืฆืืืืช ืืงืืืืืช ืืชืื ืืฉืืจื ืืคืขืืืืช ืืืืจืืช. ืจืื ืืช ืชืืขืื ืืชืืกืฃ.
ืืืืฉื
ืืืกืืคื ืืช ืืขืืจื ืืืืืืืืื ืื ืืืฆืืื ืืช ืืชืืื ืืืืฆื ืขื ื-CMS.
ืฉืืืืช ื ืคืืฆืืช
vinext ืืื ืชืืกืฃ Vite ืืงืื ืคืชืื, ืืชืืืืงืช Cloudflare, ืฉืืืืฉ ืืืืฉ ืืช ื-API ืืฆืืืืจื ืฉื Next.js: App Router ื-Pages Router, React Server Components, Server Actions, proxy.ts, route handlers ืืืืืืื next/*. ืงืื ื-Next.js ืฉืืื ืจืฅ ืขื Vite, ืื ืคืจืก ืืืืคื ืืืื ื ื-Cloudflare Workers ืื ืืคืืืคืืจืืืช ืืืจืืช ืืจื Nitro.
ืจืง ืฉืืืื ืืื ืืื. ื-Next.js, withIntlayer() ืขืืืฃ ืืช next.config.ts. ื-vinext, ืชืืกืฃ intlayer() ื-vite-intlayer ื ืื ืก ืืืงืื ืื ื-vite.config.ts. ื-providers, ื-hooks, proxy.ts, ืืืื-ืืืื ืืงืื ื-sitemap ื ืฉืืจืื ืืืื, ืืืื ืืคืฉืจ ืืขืงืื ืืืจื ืืืืจืื ื-Next.js 16 ืืื ืื ืฉืืืฃ ืืื ืื ืืืกื.
ืื. ืืฉืื i18n ื-next.config.ts ืืืกื ื-vinext ืจืง ืงืืืืืืช ืฉืคื ืฉื Pages Router, ื-Intlayer ืืืฆืข ื ืืชืื ืืฉืื ืืจื proxy.ts. ืื ืชืืกืฃ @intlayer/swc ืืื ื ื ืืืฅ: ืชืืกืฃ ื-Vite ืืืจ ืืืืืฃ ืืช ืืงืจืืืืช ื-useIntlayer ืื ืฉืื ืืฃ ืฉืืื ืจืง ืืช ืืืืืื ืื ืฉืืื ืืฉืชืืฉ ืืื. ืจืื ืืืคืืืืืืฆืืืช bundle.
ืื. ืชืืกืฃ ื-Vite โintlayer() ืืคืขืื ืืช ืืขืงื ืืชืืื ืืื ืขื vite dev, ืืขืจืืืช ืชืืื ืืขืืื ืช ืืืืืจืืช ืจืง ืืช ืืงืืืคืื ื ืืืช ืฉืงืืจืืืช ืืช ืืืืืื ืฉืฉืื ื.
ืื. ืขืงืื ืืืจื ืืืจืื ืืืขืืจ ื-next-intl ืื ืืืจืื ืืืขืืจ ื-i18next, ืื ืฉืืจื ืขื ื-API ืื ืืืื ืขื ืืชืืื ืชืืืืืช, ืฉืืืฉืคืื ืืช ื-API ืฉื next-intl, react-i18next ื-react-intl ืืขื ืืืืื ื Intlayer.
ืื. routing.mode ืืงืื:
"prefix-no-default"(ืืจืืจืช ืืืื):/aboutืืฉืคืช ืืจืืจืช ืืืืื,/fr/aboutืืฉืืจ."prefix-all": ืืื ืฉืคื ืืฉ ืงืืืืืช,/en/aboutื-/fr/about."no-prefix": ืืื ืฉืคื ืื ืชืื, ืืืื ื ืงืืขืช ื-cookie ืื ืืืืชืจืช."search-params":/about?locale=fr.
ืจืื ืืช ืืืจืื ืืขืืจ ืืชืฆืืจื ืืืช ืืืจืืืืงืืืจื ืืื ื ืชืื ืฉืคื ืืฉืื 2.
