i am currently trying to create a new dataset for each localized language , ie. spanish, russian. how can i get a studio to work on diff dataset?

8 replies
Last updated: Nov 17, 2020
hi, i am currently trying to create a new dataset for each localized language , ie. spanish, russian. how can i get a studio to work on diff dataset. ? currently my sanity deploy build to english (production) data.
AI Update

You can configure your Sanity Studio to work with multiple datasets using workspaces! This is exactly what you need for managing different language-specific datasets.

Workspaces allow you to have multiple isolated Studio configurations within a single codebase, where each workspace can connect to a different dataset. Here's how to set it up:

Basic Configuration

In your sanity.config.ts (or .js), define multiple workspaces instead of a single configuration:

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {schemaTypes} from './schemas'

export default defineConfig([
  {
    name: 'english',
    title: 'English (Production)',
    projectId: 'your-project-id',
    dataset: 'production', // your current English dataset
    plugins: [structureTool()],
    schema: {
      types: schemaTypes,
    },
    basePath: '/english',
  },
  {
    name: 'spanish',
    title: 'Spanish',
    projectId: 'your-project-id',
    dataset: 'spanish', // your Spanish dataset
    plugins: [structureTool()],
    schema: {
      types: schemaTypes,
    },
    basePath: '/spanish',
  },
  {
    name: 'russian',
    title: 'Russian',
    projectId: 'your-project-id',
    dataset: 'russian', // your Russian dataset
    plugins: [structureTool()],
    schema: {
      types: schemaTypes,
    },
    basePath: '/russian',
  },
])

What This Does

  • Creates a workspace switcher in your Studio (top left corner) where you can toggle between English, Spanish, and Russian
  • Each workspace connects to its own dataset
  • All workspaces share the same schema and codebase
  • The basePath creates unique URLs like /english, /spanish, /russian

Deployment

When you run sanity deploy, it deploys all workspaces to your hosted Studio. Users can then switch between them using the dropdown menu.

Important Notes

  1. Create the datasets first: Make sure you've created the spanish and russian datasets in your project (you can do this via the Sanity CLI with sanity dataset create spanish)

  2. Shared schema: All datasets will use the same schema definition. If you need different schemas per language, you'll need to implement conditional logic in your schema configuration based on the active workspace.

  3. Access control: You can configure different permissions per workspace if needed through your project's access settings.

This approach is much cleaner than managing separate Studio deployments and gives your content editors a seamless way to switch between language-specific content!

Hi!Not sure I understood correctly, but you can use spaces to easily change datasets in production:

https://www.sanity.io/docs/spaces
concerning localization, I wouldn't use different datasets, unless each local has unique and independant content (= no translation of content).
hi, our product is React base currently in beta, and the content is on CMS. The content on CMS needs to be translate to Spanish first. Field level wont work for this use case, document is intriguing, but ill explore Spaces.
says ‘experimental’, risk to go to production.
there’s also this plugin that is quite helpful: https://github.com/LiamMartens/sanity-plugin-intl-input
for spaces, how to create the 2nd dataset with same schema as first. i did export and import. any better approach?
yeah, I think that for now there's no better way.
Spaces work really nice!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?