I am trying to setup i18n in my Gatsby project.
I've been following this tutorial step by step:
https://www.gatsbyjs.org/blog/2017-10-17-building-i18n-with-gatsby/
First I download the required packages:
npm i -S i18next i18next-xhr-backend i18next-browser-languagedetector react-i18next
Then I set up the i18n component
import i18n from "i18next"
import Backend from "i18next-xhr-backend"
import LanguageDetector from "i18next-browser-languagedetector"
import { reactI18nextModule } from "react-i18next"
i18n
.use(Backend)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
fallbackLng: "en",
// have a common namespace used around the full app
ns: ["translations"],
defaultNS: "translations",
debug: true,
interpolation: {
escapeValue: false, // not needed for react!!
},
react: {
wait: true,
},
})
export default i18n
Imported it in my layout component:
import React from "react"
import "./layout.scss"
import NavMenu from "./NavMenu/navMenu"
import i18n from './i18n/i18n'
export default function Layout({ children }) {
return (
<div className="container">
<NavMenu />
{children}
</div>
)
}
However, when I run my app I get the following error:
Does anyone have a clue what the problem might be?
