Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Confusion about the new version of the @sanity/document-internationalization plugin and how to remove the default new document template.

6 replies
Last updated: Jun 1, 2023
Hi, so I tested the new version of the @sanity/document-internationalization plugin. However, I’m kinda confused. Where did the base language go, and why do I have 3 “Create” options when creating a new document? I have only configured 2 languages in the supportedLanguages config.
May 30, 2023, 12:11 PM
I just wanted to add that I understand the new concepts and why the base language is gone. But I still do not know why I have 3 “Create” options in the menu.
May 30, 2023, 1:34 PM
Hey Bjørn!
Base language is removed in the new version as that was the #1 feature request for the existing version. It was very limiting for teams that wanted to start a document in any language first and add translations later. This is explained in the readme I believe, but perhaps could be clearer.

Those “new” options are because the plug-in registers templates to start a document with the language field populated — but does not remove the default one. You could find instructions to remove the default new document template in the docs.

Let me know if you have any other feedback, thanks!
May 30, 2023, 9:08 PM
Hi Simeon and thanks for your reply. I tried searching for information on how to remove the default new document entry, but I could not find it. I assume it has something to do with modifying initial value templates, but I could not get any further that this:

export const SiteTemplatesNorway = (prev) => [
This, as you know, just returns whatever is there from before. What more do I need to do here?

Also, while on topic of value templates:
My “Article” document has a reference to another document called “Topic”. The “Topic” document also has document translation. Say I create a new Norwegian Article, select a “Topic” and hit publish. Then I go to the Translations button and create a English translation of this article. I now see the content from the Norwegian article copied over. This is fine. But is it possible to have the reference field use the english reference automatically, if that exists? That way the editor does not manually have to remove the Norwegian reference and re-add the English translated reference?
May 31, 2023, 6:57 AM
1. You’d need to filter that
array of templates to remove the default ones. I might add a page to the plugin docs to describe it.2. This plugin won’t be able to solve this question of “reference inheritance”, but what you could do is apply a validation rule to the document to ensure that the language of the
field matches the language of the
field so the author must replace that reference in order to publish it.
May 31, 2023, 9:29 AM
1. Think I managed to solve it by:
export const SiteTemplatesNorway = (prev) => {
    const schemas = TranslationSchemaTypesNorway;
    return prev.filter((obj) => !schemas.includes(obj.id));
Basically, ‘TranslationSchemaTypesNorway’ is the array of schemaTypes that is also defined in your plugin config. That way its always in sync.
2. Thanks. I’ll check that out.
May 31, 2023, 4:07 PM
Looks like you’ve got it sorted but I did write an extra guide for how to remove the default template:

Jun 1, 2023, 9:25 AM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?