For fields that are set not to be localised in Contentful and language fallback for foreign languages turned off in Contentful I think Gatsby should use the value of the field from the default language.
We for example have name field for each content type inside Contentful that is set not to be localised. Currently Gatsby will just set the value of name for other locales to null. The same applies for many of the images we have in Contentful that we have set not to be localised and would like to use the same image for each locale, but currently this doesn't seem to be possible.
Seems that #2539 changed the behaviour of the locale fallbacks, but this particular use case is not covered by it.
This might not be 100% in line with Contentful's behaviour, so maybe this could be configurable option in gatsby-source-contentful?
I'm happy to do a PR if you think this is legitimate suggestion.
Or is there some other way to fallback to the default locale for fields that are set not to be localised?
I'm not really sure — @kalinchernev — what do you think the right answer is from Contentful's perspective?
Oops, meant @Khaledgarbaya :-)
Hey there,
Usually Contentful handles that for you when request entries using the normal endpoints like /entries /enrtries/:entryId but since we are using the sync api for gatsby-source-contentful we need to handle that client side because we are getting all the data.
It's a little bit of work but it is not that complicated.
Ok, that explains!
@Khaledgarbaya do you wan't to check if this looks suitable solution for this?
https://github.com/freska-fi/gatsby/commit/a7cd2092741a150655277cf881748001e6ca5f57
If yes, I can add tests and submit a PR.
Thanks! :)
P.S. We love Gatsby! We at Freska are currently renewing our website with Gatsby! Nice work all of you! :)
Hi @evuolas ,
That's a good starting point. I would say you add some tests and start a PR and I will give you some more testing scenarios for your solution, once we cover all of them we can merge it.
Hi @evuolas, are you still on this PR? I would hate to steal your thunder, but I think this is still an open issue and would love to bring this issue to a close.
@evuolas @anjawaldbauer I stared a WIP PR here