Implementing GraphQL i18n support for document translations
16 replies
Last updated: Oct 10, 2022
S
Just read the documentation here for GraphQL i18n support.
https://github.com/sanity-io/document-internationalization/blob/main/docs/graphql-intl-doc.md
Where does this schema work need installing to get document level translations to work? It’s not clear from these examples.
https://github.com/sanity-io/document-internationalization/blob/main/docs/graphql-intl-doc.md
Where does this schema work need installing to get document level translations to work? It’s not clear from these examples.
Oct 10, 2022, 1:40 PM
S
Also the reference in the second block of code. What is that a reference too?
Thinking this documentation might need an update or two.
Thinking this documentation might need an update or two.
Oct 10, 2022, 2:34 PM
S
The first code example is referring to wherever you’re setting up configuration for the plugin. Most often that’s in a config file, but some put it in an
Imagine a
i18nkey right on a schema.
Imagine a
productschema, the final setup should look like this:
{ name: 'product', title: 'Product' type: 'document', i18n: { fieldNames: { lang: 'i18n_lang' baseReference: 'i18n_base', references: 'i18n_refs' } } fields: [ { name: 'i18n_lang', type: 'string', hidden: true, }, { name: 'i18n_base', type: 'reference', to: [{type: 'product'}], hidden: true, }, { name: 'i18n_refs', type: 'array', hidden: true, of: [ { type: 'reference', to: [{type: 'product'}], }, ], }, ], }
Oct 10, 2022, 2:54 PM
S
(also you’re not wrong about that code example, LMK know how you get on with what I’ve posted above)
Oct 10, 2022, 2:54 PM
S
Thanks User! Giving that a test now.
Oct 10, 2022, 2:56 PM
S
All appears to work fine from the Sanity side looking at the first screenshot with the fields made visible.
Oct 10, 2022, 3:11 PM
S
I’ve then done a
sanity startand also a
sanity graqhql deploybut cannot see the localised content anywhere?
Oct 10, 2022, 3:11 PM
S
Is that doc on the right published?
Oct 10, 2022, 3:13 PM
S
It is, yes
Oct 10, 2022, 3:14 PM
S
Your new i18n fields aren’t present in the GraphQL schema either
Oct 10, 2022, 3:14 PM
S
Sure GraphiQL is updated?
Oct 10, 2022, 3:14 PM
S
Sorted it, I was in the wrong dataset on my Gatsby build.
Oct 10, 2022, 3:16 PM
S
facepalm
Oct 10, 2022, 3:16 PM
S
success
Oct 10, 2022, 3:17 PM
S
Can’t argue with results. Got there.
Oct 10, 2022, 3:17 PM
S
I was so close to just refactoring this project into NextJS just to use groq too!
Oct 10, 2022, 3:18 PM
S
😂
Oct 10, 2022, 3:19 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.