@kaliber/sanity-plugin-multi-language
v4.2.0
Published
Document level translations.
Downloads
15
Readme
Kaliber Sanity Multi Language Plugin
Document level translations.
Installation
> yarn add @kaliber/sanity-plugin-multi-language
Usage
sanity.config.js
import { addFields as addMultiLanguageFields } from '@kaliber/sanity-plugin-multi-language'
defineConfig({
plugins: [
deskTool({
defaultDocumentNode: (S, context) => {
const getClient = context.getClient.bind(context)
const views = [
S.view.form(),
typeHasLanguage(context) && S.view
.component(Translations)
.options({ multiLanguage, reportError })
.title('Translations'),
].filter(Boolean)
return S.document().views(views)
}
}),
],
schema: {
types: (prev, context) => prev
.concat(schemaTypes)
.map(addMultiLanguageFields({ multiLanguage: clientConfig.multiLanguage, reportError })),
},
})
schema/documents/page.js
export const page = {
type: 'document',
name: 'page',
title: 'Page',
options: {
kaliber: {
multiLanguage: true,
...
},
...
},
...
}
Config
config.multiLanguage
{
defaultLanguage: 'nl',
languages: {
nl: {
title: 'Dutch',
adjective: 'dutch',
language: 'nl',
icu: 'nl_NL'
},
en: {
title: 'English',
adjective: 'english',
language: 'en',
icu: 'en_US'
}
},
}
Development
In this plugin:
> yarn
> yarn link
In your project:
> yarn link @kaliber/sanity-plugin-multi-language
Publish
yarn publish
git push
git push --tags