sanity-plugin-intl-input icon indicating copy to clipboard operation
sanity-plugin-intl-input copied to clipboard

Cannot get translation string in GraphQL

Open ymcheung opened this issue 3 years ago • 0 comments

Hi! I am using intl-input just for objects and have done the following:

intl-input.json
"languages": [
  { "name": "en", "title": "English" },
  { "name": "tw", "title": "中文" }
]
Document schema
export default {
  title: 'Media',
  name: 'media',
  type: 'document',
  fields: [
    ...
    {
      title: 'Name',
      name: 'name',
      type: 'mediaTranslate'
    },
    ...
   ]
}
export default {
  title: 'Translate',
  name: 'mediaTranslate',
  type: 'object',
  options: {
    i18n: true
  },
  fields: [{
    title: 'Translate',
    name: 'translate',
    type: 'string'
  }]
}

Then do sanity graphql deploy and try queries in playground. However, I got translation as a string and all of them are null.

type MediaTranslate {
  _key: String
  _type: String
  translate: String
}

What is the correct way to get i18n data for object level? Thank you!

ymcheung avatar Jun 23 '21 16:06 ymcheung