Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking /_app in the plugin #35

Closed
TheMatrixan opened this issue Jun 16, 2023 · 1 comment · Fixed by #43
Closed

Fix checking /_app in the plugin #35

TheMatrixan opened this issue Jun 16, 2023 · 1 comment · Fixed by #43

Comments

@TheMatrixan
Copy link
Contributor

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch next-translate-plugin@2.0.5 for the project I'm working on.

Here is the diff that solved my problem which was that plugin is not working with Next.js custom page extensions:

diff --git a/node_modules/next-translate-plugin/lib/cjs/loader.js b/node_modules/next-translate-plugin/lib/cjs/loader.js
index 686d7b1..f87ebb7 100644
--- a/node_modules/next-translate-plugin/lib/cjs/loader.js
+++ b/node_modules/next-translate-plugin/lib/cjs/loader.js
@@ -31,11 +31,11 @@ function loader(rawCode) {
         return rawCode;
     }
     if (hasGetInitialPropsOnAppJs) {
-        return pageNoExt === '/_app'
+        return pageNoExt.startsWith('/_app')
             ? (0, templateWithHoc_1.default)(pagePkg, { hasLoadLocaleFrom: hasLoadLocaleFrom })
             : rawCode;
     }
-    if (pageNoExt === '/_app') {
+    if (pageNoExt.startsWith('/_app')) {
         return (0, templateWithHoc_1.default)(pagePkg, {
             skipInitialProps: true,
             hasLoadLocaleFrom: hasLoadLocaleFrom,
diff --git a/node_modules/next-translate-plugin/lib/esm/loader.js b/node_modules/next-translate-plugin/lib/esm/loader.js
index 4950f3a..6137ff7 100644
--- a/node_modules/next-translate-plugin/lib/esm/loader.js
+++ b/node_modules/next-translate-plugin/lib/esm/loader.js
@@ -26,11 +26,11 @@ export default function loader(rawCode) {
         return rawCode;
     }
     if (hasGetInitialPropsOnAppJs) {
-        return pageNoExt === '/_app'
+        return pageNoExt.startsWith('/_app')
             ? templateWithHoc(pagePkg, { hasLoadLocaleFrom: hasLoadLocaleFrom })
             : rawCode;
     }
-    if (pageNoExt === '/_app') {
+    if (pageNoExt.startsWith('/_app')) {
         return templateWithHoc(pagePkg, {
             skipInitialProps: true,
             hasLoadLocaleFrom: hasLoadLocaleFrom,

This issue body was partially generated by patch-package.

@aralroca
Copy link
Owner

Feel free to PR @TheMatrixan 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants