Query localized data

Hey there,

I am currently having my content localized for 2 languages and I am running into the following problem. Basically I am querying all the items in one language and displaying them as links to product pages that have this structure /products/${product_id}. But when I switch languages the links are also differing. Is there a possibility to have the same product_id even though the content is different for the according to locale. Basically, if a user lands on the product page for a locale and tries to switch languages, he will be unable to do so.

Thank you in advance.

Hi @vovaturcan4, you should be able to do this. What type of field are you using for your product_id?

Hey @Levi, I am not really relying on a field where I would specify the product_id, I am using the default id of the document generated by Prismic. It is of big surprise for me that 2 localized versions of a document have different ids, would love to find out how I could unify them in one so that they become queryable.

Hi @vovaturcan4, the document ID will always be unique for each document, even if it is a translation of another document. So there isn’t any way to have Prismic serve the same ID for translations.

Instead, you’ll need to use a content field such as the UID field. The UID field allows translations to have the same UID value, which you can query by.

Give this a try and see if it works for you.

A post was split to a new topic: Trouble with multi-language and the UID field