Sanity.io offers great DX (Developer Experience) since you can pre-define your schema and using typescript you will have great control over your data and types. I hear you saying "Cut to the chase!".
Sanity offers two localization strategy;
- Field Level Translation
- Document Level Translation
In this article I will show you how you implement field level translation. This is basically you provide language fields for every field you want to create. Say you have a content type called article
and you want to add localization to the title
field in this content type.
Changing the type from string to object it can then accept multiple values.
Anndd Voila!
You can make this fields reusable by extracting it to its own type.
Add this new schema to your schema types.
Then you can reuse it for any string fields you like. You can extend this reusable schemas for other content types just like strings. It's up to your imagination. But you get the idea.