Ali
Ali

Reputation: 113

How to add next-translate to next.config

I am trying to implement more languages in my Next project and I am confused by the documentation of library next-translate.

In documentation is next.config.ts:

const nextTranslate = require('next-translate')
module.exports = nextTranslate()

But I have next.config in Next project version >12 like this (it is default):

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = nextConfig

This version of next.config not working for me - there are same code issues:

const nextTranslate = require('next-translate')

module.exports = nextTranslate({
  webpack: (config, { isServer, webpack }) => {
    return config;
  }
})

In next.config I have one module.export already, so how can I add a second module.export, or how can I implement next-translate to the next.config? Thanks.

Upvotes: 2

Views: 1990

Answers (1)

Moein Moeinnia
Moein Moeinnia

Reputation: 2341

You have to add your custom nextConfig as a parameter to nextTranslate() .

Use this code:

const nextTranslate = require('next-translate')

module.exports = nextTranslate({
  reactStrictMode: true,
  swcMinify: true
  }
})

Upvotes: 1

Related Questions