I have a question which has been driving me a bit mad for days so any help is hugely appreciated.
I'm trying to use multiple namespaces alongside using the saveMissing functionality with Locize in my next.js app. I'm passing the commonly used namespaces, as well as the current page namespace, into the serverSideTranslations function and it's loading the json translations which have been synced from Locize in the public/locales folder and displaying the translations on the page.
However when the page loads, none of the namespaces that are passed into the serverSideTranslations namespace array are being sent to the Locize API (using the saveMissing functionality). however if a namespace is not added to the serverSideTranslations namespace array, it is correctly sent to the Locize API. So it seems that any namespaces being passed into serverSideTranslations just aren't being sent to Locize (but the API requests are working otherwise). All on localhost.
Does anyone have any ideas why this might be? I'm happy to give more information/supply more code if needs be. Thanks!
next-i18next.config.js:
...
...
const isBrowser = typeof window !== 'undefined';
const settings = {
lowerCaseLng: true,
backend: {
projectId: process.env.NEXT_PUBLIC_LOCIZE_PROJECT_ID || '',
apiKey: process.env.NEXT_PUBLIC_LOCIZE_SECRET,
version: 'latest',
},
serializeConfig: false,
use: isBrowser ? [LocizeBackend] : [],
saveMissing: true,
nsSeparator: false,
keySeparator: false,
};
module.exports = {
i18n: {
locales: [...ACCEPTED_LOCALES],
defaultLocale: DEFAULT_LOCALE,
localeDetection: false,
},
...settings,
};
example page (index.txs):
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import nextI18NextConfig from '../../next-i18next.config.js';
export async function getStaticProps(context) {
return {
props: {
...(await serverSideTranslations(
context.locale || context.defaultLocale || 'en-us',
['common', 'form', 'ctas', 'homepage'],
nextI18NextConfig,
)),
namespace: 'homepage',
},
};
}
...
...
I've tried various combinations of properties in the config file, but nothing has helped so far.