Integration with NextJs, _next/data after build change response object. #1988
Unanswered
Vin-dellavv
asked this question in
Q&A
Replies: 1 comment 8 replies
-
Hey, this seems like some issue with next.js configuration and with passing the data to props, however I'd need to see a whole configuration, I can't pinpont the issue from this partial example. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings,
First timer with tolgee and fairly a neophyte with nextjs.
After integrating I notice a different behavior of the TolgeeProvider between the local version and the build one.
In the local version it manages to correctly fetch the namespace that is administered in the init, in the builtin instead the call is intercepted by next which places it under _next/data but adding "pageProps" as the first level of the response object practically prevents the keys from being correctly fetched.
I need to add some other param to my init config? (doc wasn't very clear about)
// Init plugin
const tolgee = Tolgee()
.use(LanguageDetector())
.use(FormatIcu())
.use(DevTools())
.init({
availableLanguages: ["en", "it", "de"],
defaultLanguage: "en",
apiKey: TOLGEE_API_KEY,
apiUrl: TOLGEE_API_URL,
ns: [TOGLEE_NAMESPACE],
defaultNs: TOGLEE_NAMESPACE,
staticData: {
de: deLocale,
en: enLocale,
it: itLocale
}
});
export const getServerLocales = async (
locale: string | undefined,
ns?: NsFallback
) => {
const namespaces = ["", ...getFallbackArray(ns)];
const result: Record<string, any> = {};
};
Here a response example on local:
{
"en": {
"COMMON": {
"BUTTONS": {...}
...
}
...
}
}
to this url:
https://privacy.com/v2/projects/64/translations/en?ns=test
and response on build-ed version:
{
"pageProps": {
"en": {
"COMMON": {
"BUTTONS": { ... },
...
}
...
}
}
}
to this url: http://localhost:3000/_next/data/"randomUID"/en.json
Beta Was this translation helpful? Give feedback.
All reactions