Modified version of next-i18next "simple" example.
Showcases the ability to load translations conditionally from a directory other than public
based on the namespace (or locale).
next-i18next.config.js, uses a localePath
function which checks the namespace. In order for next-i18next to work, ns
and serializeConfig: false
need to be provided.
Passing the next-i18next configuration to appWithTranslation
in ./pages/_app.tsx and each page's serverSideTranslations
.
The footer
content is loaded from non-public
(node_modules
also works but only tested on Mac where cp
is available, after running npm run dev:setup
).
localePath(locale, namespace) {
if (namespace === 'footer') {
return `./non-public/locales/${locale}/${namespace}.json`;
}
return `./public/locales/${locale}/${namespace}.json`;
},