I am having a Nextjs Typescript application in which I am trying to implement next-i18nnext for internationalization
This is my next-i18next.config.mjs file
import path from 'path';
const nextI18NextConfig = {
debug: process.env.NODE_ENV == 'development',
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'], // Add more locales if needed
},
// Direct path to the locale files
localePath: typeof window === 'undefined' ? path.resolve('./public/locales') : '/locales',
fallbackLng: 'en',
interpolation: {
escapeValue: false, // not needed for React
},
};
export default nextI18NextConfig;
I want to keep the language files as public/locales/en.json, public/locales/fr.json
but I am not able to read them during translations because this expects the default folder structure as
public/locales/en/common.json
and so on.
How can I achieve the customization I mentioned above. What changes I need to do in next-i18next.config.mjs file