I'm trying to implement i18n-perser
with Next Js. According to the i18n-perser
documentation I need to create a gulpfile.js
on the root directory. My gulpfile.js
is something like this.
import gulp from 'gulp';
import { gulp as i18nextParser } from 'i18next-parser';
export async function i18next() {
return gulp
.src('./**')
.pipe(
new i18nextParser({
locales: ['en', 'nl'],
output: './i18n/locales/$LOCALE/$NAMESPACE.json',
})
)
.pipe(gulp.dest('./'));
}
It's gives me SyntaxError: Cannot use import statement outside a module
. I tried some solution like the dynamic import. But it's not working for me in this case. It's giving me the same SyntaxError
.
import dynamic from 'next/dynamic';
const gulp = dynamic(() => import('gulp'), { ssr: false });
const { gulp: i18nextParser } = dynamic(() => import('i18next-parser"'), { ssr: false });
I triend the dynamic import
but it's also not working in my case. It's working perfectly in React
but not working with NextJs
. Basiclly if I run npm run gulp
it will create parer file for me.