Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-mangos-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sanity/document-internationalization": minor
---

Add support for disabling the automatic template creation via the `addTemplates` config option
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const DEFAULT_CONFIG: PluginConfigContext = {
allowCreateMetaDoc: false,
callback: null,
hideLanguageFilter: false,
addTemplates: true,
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const documentInternationalization = definePlugin<PluginConfig>((config)
metadataFields,
hideLanguageFilter,
metadataInternationalization,
addTemplates,
} = pluginConfig

if (schemaTypes.length === 0) {
Expand Down Expand Up @@ -129,6 +130,10 @@ export const documentInternationalization = definePlugin<PluginConfig>((config)
// For every schema type this plugin is enabled on
// Create an initial value template to set the language
templates: (prev, {schema}) => {
if (!addTemplates) {
return prev
}

// Templates are not setup for async languages
if (!Array.isArray(supportedLanguages)) {
return prev
Expand Down
4 changes: 4 additions & 0 deletions plugins/@sanity/document-internationalization/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export type PluginConfig = {
InternationalizedArrayPluginConfig,
'buttonLocations' | 'buttonAddAll' | 'languageDisplay'
>
/**
* Set to false to prevent templates from being created for each schemaType and language.
*/
addTemplates?: boolean
}

// Context version of config
Expand Down
Loading