Closed jgdemattos closed 1 year ago
I'm facing the same issue.
If a locale is not defined on a field level the secondary locale is returned even if a fallback locale is set to the primary locale.
Doesn't affect development.
Facing the same issue, not on a development but on every build.
export const pageQuery = graphql`
query HomePage($locale: String!) {
datoCmsGlobalConfiguration(locale: $locale) {
id
websiteName
...CookiesBannerFields
}
}
`
here is my gatsby-node just to show that I'm creating the same page on different languages :
async function generateHomePage() {
const index = path.resolve(`./src/templates/index.tsx`)
allLocales.data.datoCmsSite.locales.forEach(locale => {
createPage({
path: locale === defaultLocale ? "/" : `/${locale}`,
component: index,
context: {
locale,
defaultLocale,
slugs: allMainSlugs,
},
})
})
}
and as you can see in my context the locale is "fr" and the data returned is in english
Hey folks, I opened PR with potential fix for those issues in https://github.com/datocms/gatsby-source-datocms/pull/211
Issue when querying a document with the locale argument at document level, like the the query below:
This query will, sometimes, ramdomly return fields in the wrong language when building the site. This happens mostly in production.
As an example, if the $language is PT, portuguese, I will get fields in EN, english.
The safe way to ensure the correct field language, is to use the locale argument at field level, like below: