Document vs. Field Level Localization for Large Numbers of Languages

3 replies
Last updated: Aug 6, 2021
This way of doing localization works great when you have 2-3 languages. But let's say you have 10 different languages, this becomes really noisy to have all listed for every text field in a document. Is there any good alternative to solve this? Document level localization is not an option, as we might want to share some fields (e.g. images etc.).
Aug 6, 2021, 7:48โ€ฏAM
Could you create a custom object input component that accept arbitrary fields, but split them into as many languages as necessary? i.e

import { createLocalizer } from 'sanity-localize'

const localize = createLocalizer({
  langs: ['en', 'ko', 'zh'],
})

export default {
  type: 'document',
  name: '..'
  fields: [
    localize({
      title: 'Title',
      name: 'title',
      type: 'string',
    })
  ]
}
would yield something like

{
  title: {
    en: 'Hello',
    ko: '์•ˆ๋…•',
    zh: 'Nihao'
  },
}
In the UI itโ€™d be a single input field, but with tabs:


Title

|*EN*| KO | ZH |
-----------------------------
| Hello                     |
-----------------------------
This is what I did with NetlifyCMS before it supports i18n natively, worked out pretty well
Aug 6, 2021, 8:55โ€ฏAM
Aug 6, 2021, 9:01โ€ฏAM
Thank you all for great feedback. I will go through them and take a look at each one. ๐Ÿ™‚
Aug 6, 2021, 2:30โ€ฏPM

Sanity.io โ€“ build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.