Skip to content

Commit

Permalink
feat: use translationTab mergeWithTargetLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez committed May 6, 2024
1 parent 896be39 commit ce55dfc
Show file tree
Hide file tree
Showing 3 changed files with 9,279 additions and 7,197 deletions.
26 changes: 16 additions & 10 deletions docs/01-advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ This plugin provides defaults for most configuration options, but they can be ov

```typescript
//sanity.config.ts
import {TranslationsTab, defaultDocumentLevelConfig, defaultFieldLevelConfig, TranslationsTabConfigOptions} from 'sanity-plugin-studio-smartling'
import {
TranslationsTab,
defaultDocumentLevelConfig,
defaultFieldLevelConfig,
type TranslationsTabConfigOptions,
} from 'sanity-plugin-studio-smartling'

const customConfig = {
...defaultDocumentLevelConfig,
//baseLanguage is `en` by default, overwrite as needed. This is important for coalescing translations and creating accurate translation metadata.
baseLanguage: 'en_US',
baseLanguage: 'en_US',
//this is the field that will be used to determine the language of the document. It is `language` by default.
languageField: 'locale',
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.
additionalStopTypes: ['colorTheme'],
Expand All @@ -21,17 +26,17 @@ const customConfig = {
additionalSerializers: {
testObject: ({value}) => {
return `<span class="${value._type}" id="${value._key}">${value.title}</span>`
}
},
},
//Create a method to deserialize any custom serialization rules
additonalDeserializers: {
testObject: ({node}) => {
return {
_type: 'testObject',
_key: node.id,
title: node.innerHTML
title: node.textContent,
}
}
},
},
//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: [
Expand All @@ -53,11 +58,12 @@ const customConfig = {
}
},
},
]
],
},
// GET request that creates a callback to a URL when a file is 100% published for a locale.
// The callback gives the fileUri and locale with the format http[/s]://your.url?locale=xx-XX&fileUri=your.file.
callbackUrl: 'https://your-endpoint.here'
//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.
} satisfies TranslationsTabConfigOptions

Expand Down
Loading

0 comments on commit ce55dfc

Please sign in to comment.