Page Logo
Ahmet Ulutaş
web-development

Field Level Translation with Sanity.io in Next.js 13

Image for undefined
Ahmet Ulutaş

Ahmet Ulutaş

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;

  1. Field Level Translation
  2. 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.

Loading...

Changing the type from string to object it can then accept multiple values.

Loading...

Anndd Voila!

Field level translation in sanity.io
The result of field level translation

You can make this fields reusable by extracting it to its own type.

Loading...

Add this new schema to your schema types.

Loading...

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.

Loading...

Comments

Loading...
Table of Content

    More Blogs