Skip to content

Commit

Permalink
Update 01-advanced-configuration.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez authored Sep 26, 2024
1 parent 22c67ce commit 54ac5d3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs/01-advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This plugin provides defaults for most configuration options, but they can be overridden as needed. Please refer to the types to see what you should declare, but we also provide the type for all options, which we recommend using for quicker development.

```typescript
//sanity.config.ts
// sanity.config.ts
import {
TranslationsTab,
defaultDocumentLevelConfig,
Expand All @@ -13,22 +13,22 @@ import {

const customConfig = {
...defaultDocumentLevelConfig,
//baseLanguage is `en` by default, overwrite as needed. This is important for coalescing translations and creating accurate translation metadata.
// baseLanguage is `en` by default, overwrite as needed. This is important for coalescing translations and creating accurate translation metadata.
baseLanguage: 'en_US',
//this is the field that will be used to determine the language of the document. It is `language` by default.
// this is the field that will be used to determine the language of the document. It is `language` by default.
languageField: 'locale',
serializationOptions: {
//use this option to exclude objects that do not need to be translated. The plugin already uses defaults for references, dates, numbers, etc.
// use this option to exclude objects that do not need to be translated. The plugin already uses defaults for references, dates, numbers, etc.
additionalStopTypes: ['colorTheme'],
//use this option to serialize objects in a particular way. The plugin will try to filter and serialize objects as best as it can, but you can override this behavior here.
//For now, you should also include these for annotations and inline objects in PortableText, if you want them to be translated.
//NOTE: it is VERY important to include the _type as a class and the _key as id for accurately deserializing and coalescing
// use this option to serialize objects in a particular way. The plugin will try to filter and serialize objects as best as it can, but you can override this behavior here.
// For now, you should also include these for annotations and inline objects in PortableText, if you want them to be translated.
// NOTE: it is VERY important to include the _type as a class and the _key as id for accurately deserializing and coalescing
additionalSerializers: {
testObject: ({value}) => {
return `<span class="${value._type}" id="${value._key}">${value.title}</span>`
},
},
//Create a method to deserialize any custom serialization rules
// Create a method to deserialize any custom serialization rules
additonalDeserializers: {
testObject: ({node}) => {
return {
Expand All @@ -38,7 +38,7 @@ const customConfig = {
}
},
},
//Block text requires a special deserialization format based on @sanity/block-tools. Use this option for any annotations or inline objects that need to be translated.
// Block text requires a special deserialization format based on @sanity/block-tools. Use this option for any annotations or inline objects that need to be translated.
additionalBlockDeserializers: [
{
deserialize(el, next): TypedObject | undefined {
Expand All @@ -60,11 +60,11 @@ const customConfig = {
},
],
},
//sometimes editors will duplicate a field or document and begin changing assets
//THEN import the translation. this option merges your translated strings with
//the already-existing translated document or field.
// sometimes editors will duplicate a field or document and begin changing assets
// THEN import the translation. this option merges your translated strings with
// the already-existing translated document or field.
mergeWithTargetLocale: true,
//adapter, baseLanguage, secretsNamespace, importTranslation, exportForTranslation should likely not be touched unless you very much want to customize your plugin.
// adapter, baseLanguage, secretsNamespace, importTranslation, exportForTranslation should likely not be touched unless you very much want to customize your plugin.
} satisfies TranslationsTabConfigOptions


Expand Down

0 comments on commit 54ac5d3

Please sign in to comment.