Skip to content

Commit

Permalink
fix: remove config that is not serializable for client components (#51)
Browse files Browse the repository at this point in the history
Fixes #50
  • Loading branch information
aralroca authored Jun 27, 2023
1 parent 4ba2b57 commit 06b9450
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
76 changes: 38 additions & 38 deletions __tests__/__snapshots__/templateAppDir.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Error() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -59,7 +59,7 @@ function Error() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -105,7 +105,7 @@ function Error() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -151,7 +151,7 @@ function Error() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -197,7 +197,7 @@ function GlobalError() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -243,7 +243,7 @@ function GlobalError() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -289,7 +289,7 @@ function GlobalError() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -335,7 +335,7 @@ function GlobalError() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -381,7 +381,7 @@ function Layout() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -427,7 +427,7 @@ function Layout() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -473,7 +473,7 @@ function Layout() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -519,7 +519,7 @@ function Layout() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -565,7 +565,7 @@ function Loading() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -611,7 +611,7 @@ function Loading() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -657,7 +657,7 @@ function Loading() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -703,7 +703,7 @@ function Loading() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -749,7 +749,7 @@ function NotFound() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -795,7 +795,7 @@ function NotFound() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -841,7 +841,7 @@ function NotFound() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -887,7 +887,7 @@ function NotFound() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -934,7 +934,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -981,7 +981,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1028,7 +1028,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1075,7 +1075,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1122,7 +1122,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1169,7 +1169,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1216,7 +1216,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1263,7 +1263,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1309,7 +1309,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1355,7 +1355,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1401,7 +1401,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1447,7 +1447,7 @@ function Page() {

export default async function __Next_Translate_new__88d9831a00__(props) {
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale:
props.params?.lang ??
props.searchParams?.lang ??
Expand Down Expand Up @@ -1544,7 +1544,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/about/us/\\",
Expand Down Expand Up @@ -1600,7 +1600,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/\\",
Expand Down Expand Up @@ -1656,7 +1656,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/\\",
Expand Down Expand Up @@ -1743,7 +1743,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/about/us/\\",
Expand Down Expand Up @@ -1794,7 +1794,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/\\",
Expand Down Expand Up @@ -1845,7 +1845,7 @@ export default function __Next_Translate_new__88d9831a00__(props) {
const lang =
params.lang ?? searchParams.get(\\"lang\\") ?? __i18nConfig.defaultLocale;
const config = {
...__i18nConfig,
...JSON.parse(JSON.stringify(__i18nConfig)),
locale: lang,
loaderName: \\"client /page\\",
pathname: \\"/\\",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-translate-plugin",
"version": "2.4.2",
"version": "2.4.3",
"description": "Tiny and powerful i18n plugin to translate your Next.js pages.",
"license": "MIT",
"keywords": [
Expand Down
12 changes: 6 additions & 6 deletions src/templateAppDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ function templateRSCPage({
export default async function __Next_Translate_new__${hash}__(props) {
const config = {
...${INTERNAL_CONFIG_KEY},
...JSON.parse(JSON.stringify(${INTERNAL_CONFIG_KEY})),
locale: props.params?.lang ?? props.searchParams?.lang ?? ${INTERNAL_CONFIG_KEY}.defaultLocale,
loaderName: 'server ${routeType}',
pathname: '${pathname}'
}
const { __lang, __namespaces } = await __loadNamespaces({ ...config, ${addLoadLocalesFrom(
existLocalesFolder
)} });
existLocalesFolder
)} });
globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, config }
return <AppDirI18nProvider lang={__lang} namespaces={__namespaces} config={config}><${pageVariableName} {...props} /></AppDirI18nProvider>
Expand Down Expand Up @@ -146,15 +146,15 @@ function templateRCCPage({
const params = __useParams()
const lang = params.lang ?? searchParams.get('lang') ?? ${INTERNAL_CONFIG_KEY}.defaultLocale
const config = {
...${INTERNAL_CONFIG_KEY},
...JSON.parse(JSON.stringify(${INTERNAL_CONFIG_KEY})),
locale: lang,
loaderName: 'client ${routeType}',
pathname: '${pathname}',
}
const { __lang, __namespaces } = __use(__loadNamespaces({ ...config, ${addLoadLocalesFrom(
existLocalesFolder
)} }));
existLocalesFolder
)} }));
globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, config }
return <${pageVariableName} {...props} />
Expand Down

0 comments on commit 06b9450

Please sign in to comment.