Querying for default locale docs when specific locale docs are missing in multi-lingual project
Last updated: May 12, 2021
Hello! I am working on a multi-lingual project. Which has 3 locales en-SG, en-VN, and vi-VN. Among them, en-SG is a default locale. Is this possible to query the docs in a way so that when there is no doc for any locale(especially en-VN) the site shows the default locale doc?
I have achieved something similar with this query.
But it's not working properly when the $locale doc available, it's querying the $locale doc and $defaultLocale doc at the same time. And showing the $defaultLocale doc instead of the actual $locale doc on some pages.
This would return two results if there is a locale-specific document, right? One result for the locale-specific one, and one result for the default one. So on the client side you’d have to look at the results and pick the right one.
May 9, 2021, 10:30 AM
There’s a way you can do this in a single query. It’s a bit hacky, but it will work.