LiamMartens/sanity-plugin-intl-input

Getting base document from translated document

darenmalfait opened this issue · 3 comments

Issue

Having a document wide translation:
getting a translated page as starting point has no way to get the original document and/or other translated documents

What I would like
Having a way to get the related documents from any of the translations, including the base document.

Possible solution?
Keeping the document_id without the i18n. part so it can be used to start a new filter.

@daren-malfait you can use a references(i18n.base-id.lang-cult) -- but as stated in the documentation the translated document structure is based off the base document anyways so you can always just strip out the i18n parts of the id to get the base document id (ref documentation)

eg 'i18n.basedoc-id'.split('.')[1]

fev4 commented

I just faced this same question and I was thinking, would it be better (from a querying perspective) to add a ref from the translated doc to the base doc?, this reference can also point to other translations available.

Basically having bidirectional relationships

@fev4 I get the idea but I think that would complicate the data structure too much; if you think about relations in databases you generally only have a singular link between 2 objects (one referencing to the other) - but not backwards because that would require a lot more maintenance and updates. I believe with the current data structure it is generally possible to achieve most if not all use cases.