Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-translate-plugin

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-translate-plugin - npm Package Compare versions

Comparing version 2.3.0-canary.5 to 2.3.0-canary.6

4

lib/cjs/templateAppDir.js

@@ -23,3 +23,3 @@ "use strict";

return templateAppDirClientPage({ pagePkg: pagePkg, hash: hash, pageVariableName: pageVariableName, pathname: pathname });
return "\n import ".concat(utils_1.INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces from 'next-translate/loadNamespaces'\n ").concat(code, "\n\n globalThis.i18nConfig = ").concat(utils_1.INTERNAL_CONFIG_KEY, "\n\n ").concat(dynamicExport, "\n\n export default async function __Next_Translate_new__").concat(hash, "__(props) {\n let config = { \n ...").concat(utils_1.INTERNAL_CONFIG_KEY, ",\n locale: props.searchParams?.lang,\n loaderName: `${dynamic} (server page)`,\n pathname: '").concat(pathname, "',\n ").concat((0, utils_1.addLoadLocalesFrom)(), "\n }\n \n if (!globalThis.__NEXT_TRANSLATE__) {\n globalThis.__NEXT_TRANSLATE__ = {}\n }\n \n const { __lang, __namespaces } = await __loadNamespaces(config)\n globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, pathname: '").concat(pathname, "' }\n\n return (\n <>\n <div \n id=\"__NEXT_TRANSLATE_DATA__\" \n data-lang={__lang} \n data-ns={JSON.stringify(__namespaces)}\n data-pathname=\"").concat(pathname, "\"\n />\n <").concat(pageVariableName, " {...props} />\n </>\n )\n }\n");
return "\n import ".concat(utils_1.INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces from 'next-translate/loadNamespaces'\n ").concat(code, "\n\n globalThis.i18nConfig = ").concat(utils_1.INTERNAL_CONFIG_KEY, "\n\n ").concat(dynamicExport, "\n\n export default async function __Next_Translate_new__").concat(hash, "__(props) {\n let config = { \n ...").concat(utils_1.INTERNAL_CONFIG_KEY, ",\n locale: props.searchParams?.lang ?? props.params?.lang,\n loaderName: `${dynamic} (server page)`,\n pathname: '").concat(pathname, "',\n ").concat((0, utils_1.addLoadLocalesFrom)(), "\n }\n \n if (!globalThis.__NEXT_TRANSLATE__) {\n globalThis.__NEXT_TRANSLATE__ = {}\n }\n \n const { __lang, __namespaces } = await __loadNamespaces(config)\n globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, pathname: '").concat(pathname, "' }\n\n return (\n <>\n <div \n id=\"__NEXT_TRANSLATE_DATA__\" \n data-lang={__lang} \n data-ns={JSON.stringify(__namespaces)}\n data-pathname=\"").concat(pathname, "\"\n />\n <").concat(pageVariableName, " {...props} />\n </>\n )\n }\n");
}

@@ -41,3 +41,3 @@ exports.default = templateAppDir;

utils_1.clientLine.forEach(function (line) { clientCode = clientCode.replace(line, ''); });
return "".concat(topLine, "\n import ").concat(utils_1.INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces, { log as __log } from 'next-translate/loadNamespaces'\n import { useSearchParams as __useSearchParams } from 'next/navigation'\n import * as __react from 'react'\n\n ").concat(clientCode, "\n\n export default function __Next_Translate_new__").concat(hash, "__(props) {\n const forceUpdate = __react.useReducer(() => [])[1]\n const pathname = '").concat(pathname, "'\n const isServer = typeof window === 'undefined'\n let lang = __useSearchParams().get('lang')\n\n const config = { \n ...").concat(utils_1.INTERNAL_CONFIG_KEY, ",\n locale: lang,\n loaderName: 'useEffect (client page)',\n pathname,\n ").concat((0, utils_1.addLoadLocalesFrom)(), "\n }\n\n __react.useEffect(() => {\n const shouldLoad = lang !== window.__NEXT_TRANSLATE__?.lang || pathname !== window.__NEXT_TRANSLATE__?.pathname\n\n if (!shouldLoad) return\n\n __loadNamespaces(config).then(({ __lang, __namespaces }) => {\n window.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces || {}, pathname: '").concat(pathname, "' }\n window.i18nConfig = ").concat(utils_1.INTERNAL_CONFIG_KEY, "\n forceUpdate()\n })\n }, [lang])\n\n if (isServer) {\n __log(config, { page: pathname, lang, namespaces: ['calculated in client-side'] })\n return null\n }\n\n if (!window.__NEXT_TRANSLATE__) return null\n\n return <").concat(pageVariableName, " {...props} />\n }\n ");
return "".concat(topLine, "\n import ").concat(utils_1.INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces, { log as __log } from 'next-translate/loadNamespaces'\n import { useSearchParams as __useSearchParams, useParams as __useParams } from 'next/navigation'\n import * as __react from 'react'\n\n ").concat(clientCode, "\n\n export default function __Next_Translate_new__").concat(hash, "__(props) {\n const forceUpdate = __react.useReducer(() => [])[1]\n const pathname = '").concat(pathname, "'\n const isServer = typeof window === 'undefined'\n const searchParams = __useSearchParams()\n const params = __useParams()\n let lang = searchParams.get('lang') ?? params.lang\n\n const config = { \n ...").concat(utils_1.INTERNAL_CONFIG_KEY, ",\n locale: lang,\n loaderName: 'useEffect (client page)',\n pathname,\n ").concat((0, utils_1.addLoadLocalesFrom)(), "\n }\n\n __react.useEffect(() => {\n const shouldLoad = lang !== window.__NEXT_TRANSLATE__?.lang || pathname !== window.__NEXT_TRANSLATE__?.pathname\n\n if (!shouldLoad) return\n\n __loadNamespaces(config).then(({ __lang, __namespaces }) => {\n window.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces || {}, pathname: '").concat(pathname, "' }\n window.i18nConfig = ").concat(utils_1.INTERNAL_CONFIG_KEY, "\n forceUpdate()\n })\n }, [lang])\n\n if (isServer) {\n __log(config, { page: pathname, lang, namespaces: ['calculated in client-side'] })\n return null\n }\n\n if (!window.__NEXT_TRANSLATE__) return null\n\n return <").concat(pageVariableName, " {...props} />\n }\n ");
}

@@ -44,0 +44,0 @@ function modifyNamedExportsComponents(pagePkg, hash) {

@@ -21,3 +21,3 @@ import { interceptExport, addLoadLocalesFrom, getNamedExport, clientLine, interceptNamedExportsFromReactComponents, INTERNAL_CONFIG_KEY } from "./utils";

return templateAppDirClientPage({ pagePkg: pagePkg, hash: hash, pageVariableName: pageVariableName, pathname: pathname });
return "\n import ".concat(INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces from 'next-translate/loadNamespaces'\n ").concat(code, "\n\n globalThis.i18nConfig = ").concat(INTERNAL_CONFIG_KEY, "\n\n ").concat(dynamicExport, "\n\n export default async function __Next_Translate_new__").concat(hash, "__(props) {\n let config = { \n ...").concat(INTERNAL_CONFIG_KEY, ",\n locale: props.searchParams?.lang,\n loaderName: `${dynamic} (server page)`,\n pathname: '").concat(pathname, "',\n ").concat(addLoadLocalesFrom(), "\n }\n \n if (!globalThis.__NEXT_TRANSLATE__) {\n globalThis.__NEXT_TRANSLATE__ = {}\n }\n \n const { __lang, __namespaces } = await __loadNamespaces(config)\n globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, pathname: '").concat(pathname, "' }\n\n return (\n <>\n <div \n id=\"__NEXT_TRANSLATE_DATA__\" \n data-lang={__lang} \n data-ns={JSON.stringify(__namespaces)}\n data-pathname=\"").concat(pathname, "\"\n />\n <").concat(pageVariableName, " {...props} />\n </>\n )\n }\n");
return "\n import ".concat(INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces from 'next-translate/loadNamespaces'\n ").concat(code, "\n\n globalThis.i18nConfig = ").concat(INTERNAL_CONFIG_KEY, "\n\n ").concat(dynamicExport, "\n\n export default async function __Next_Translate_new__").concat(hash, "__(props) {\n let config = { \n ...").concat(INTERNAL_CONFIG_KEY, ",\n locale: props.searchParams?.lang ?? props.params?.lang,\n loaderName: `${dynamic} (server page)`,\n pathname: '").concat(pathname, "',\n ").concat(addLoadLocalesFrom(), "\n }\n \n if (!globalThis.__NEXT_TRANSLATE__) {\n globalThis.__NEXT_TRANSLATE__ = {}\n }\n \n const { __lang, __namespaces } = await __loadNamespaces(config)\n globalThis.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces, pathname: '").concat(pathname, "' }\n\n return (\n <>\n <div \n id=\"__NEXT_TRANSLATE_DATA__\" \n data-lang={__lang} \n data-ns={JSON.stringify(__namespaces)}\n data-pathname=\"").concat(pathname, "\"\n />\n <").concat(pageVariableName, " {...props} />\n </>\n )\n }\n");
}

@@ -38,3 +38,3 @@ function templateAppDirClientComponent(_a) {

clientLine.forEach(function (line) { clientCode = clientCode.replace(line, ''); });
return "".concat(topLine, "\n import ").concat(INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces, { log as __log } from 'next-translate/loadNamespaces'\n import { useSearchParams as __useSearchParams } from 'next/navigation'\n import * as __react from 'react'\n\n ").concat(clientCode, "\n\n export default function __Next_Translate_new__").concat(hash, "__(props) {\n const forceUpdate = __react.useReducer(() => [])[1]\n const pathname = '").concat(pathname, "'\n const isServer = typeof window === 'undefined'\n let lang = __useSearchParams().get('lang')\n\n const config = { \n ...").concat(INTERNAL_CONFIG_KEY, ",\n locale: lang,\n loaderName: 'useEffect (client page)',\n pathname,\n ").concat(addLoadLocalesFrom(), "\n }\n\n __react.useEffect(() => {\n const shouldLoad = lang !== window.__NEXT_TRANSLATE__?.lang || pathname !== window.__NEXT_TRANSLATE__?.pathname\n\n if (!shouldLoad) return\n\n __loadNamespaces(config).then(({ __lang, __namespaces }) => {\n window.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces || {}, pathname: '").concat(pathname, "' }\n window.i18nConfig = ").concat(INTERNAL_CONFIG_KEY, "\n forceUpdate()\n })\n }, [lang])\n\n if (isServer) {\n __log(config, { page: pathname, lang, namespaces: ['calculated in client-side'] })\n return null\n }\n\n if (!window.__NEXT_TRANSLATE__) return null\n\n return <").concat(pageVariableName, " {...props} />\n }\n ");
return "".concat(topLine, "\n import ").concat(INTERNAL_CONFIG_KEY, " from '@next-translate-root/i18n'\n import __loadNamespaces, { log as __log } from 'next-translate/loadNamespaces'\n import { useSearchParams as __useSearchParams, useParams as __useParams } from 'next/navigation'\n import * as __react from 'react'\n\n ").concat(clientCode, "\n\n export default function __Next_Translate_new__").concat(hash, "__(props) {\n const forceUpdate = __react.useReducer(() => [])[1]\n const pathname = '").concat(pathname, "'\n const isServer = typeof window === 'undefined'\n const searchParams = __useSearchParams()\n const params = __useParams()\n let lang = searchParams.get('lang') ?? params.lang\n\n const config = { \n ...").concat(INTERNAL_CONFIG_KEY, ",\n locale: lang,\n loaderName: 'useEffect (client page)',\n pathname,\n ").concat(addLoadLocalesFrom(), "\n }\n\n __react.useEffect(() => {\n const shouldLoad = lang !== window.__NEXT_TRANSLATE__?.lang || pathname !== window.__NEXT_TRANSLATE__?.pathname\n\n if (!shouldLoad) return\n\n __loadNamespaces(config).then(({ __lang, __namespaces }) => {\n window.__NEXT_TRANSLATE__ = { lang: __lang, namespaces: __namespaces || {}, pathname: '").concat(pathname, "' }\n window.i18nConfig = ").concat(INTERNAL_CONFIG_KEY, "\n forceUpdate()\n })\n }, [lang])\n\n if (isServer) {\n __log(config, { page: pathname, lang, namespaces: ['calculated in client-side'] })\n return null\n }\n\n if (!window.__NEXT_TRANSLATE__) return null\n\n return <").concat(pageVariableName, " {...props} />\n }\n ");
}

@@ -41,0 +41,0 @@ function modifyNamedExportsComponents(pagePkg, hash) {

{
"name": "next-translate-plugin",
"version": "2.3.0-canary.5",
"version": "2.3.0-canary.6",
"description": "Tiny and powerful i18n plugin to translate your Next.js pages.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc