sanity-io / document-internationalization

Create unique translations of a document based on its language, joined by a shared reference document
MIT License
131 stars 38 forks source link

Simple(?) use case help #169

Open ottob opened 9 months ago

ottob commented 9 months ago

Is your feature request related to a problem? Please describe. First of all thanks for a very nice tool! But some more use case examples would be very helpful.

Let's say I want to add a book to Sanity and translate it using document-internationalization. A book has many chapters and chapters have many pages.

My first approach was to use document-level translations for the book, chapters and pages. So I added a Swedish book that have references to chapters:

    defineField({
      name: 'chapters',
      title: 'Chapters',
      type: 'array',
      of: [{type: 'reference', to: {type: 'chapter'}}]
    }),
    // which has references to pages:
    defineField({
      name: 'pages',
      title: 'Pages',
      type: 'array',
      of: [{type: 'reference', to: {type: 'page'}}]}),

Then I added the first Swedish chapter as a reference to the Swedish book. And repeated this process for the Swedish pages. This works quite well. It's nice being able to for example visually reorder chapters using drag and drop. But when I want to add a Norwegian translation of the book I have to redo the entire process, but backwards. Create new Norwegian translation copies of the pages. New copies of all the chapters, and add the Norwegian pages to the Norwegian chapters etc. This does not feel like a sane approach 😅. Consider that we might have 100 chapters and a factor more pages.

I then thought it might be better to use field level translations for the book and chapters. Since they only change very little between translations. But even if I have a single field level translated chapter, I need to add pages to it. And I do not want to reference a specific translation of the page.

If I added a reference to the field level translated chapter to the page (reverse the reference, page -> chapter instead of chapter -> page), it could possibly work. But then I would lose the ability to reorder pages in chapter visually. I could add a sort order number, but that would not be as nice.

Please help me, it feels like I'm missing something obvious here. Happy holidays! 🎄