LiamMartens / sanity-plugin-intl-input

Intl input for Sanity with a cleaner UI than a default solution
MIT License
111 stars 22 forks source link

Cannot get translation string in GraphQL #57

Open ymcheung opened 3 years ago

ymcheung commented 3 years ago

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!