@kaliber/sanity-plugin-multi-language

3.2.0 • Public • Published

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

Package Sidebar

Install

npm i @kaliber/sanity-plugin-multi-language

Weekly Downloads

3

Version

3.2.0

License

MIT

Unpacked Size

27.9 kB

Total Files

20

Last publish

Collaborators

  • melissabos18
  • janbru
  • albertkaliber
  • jerryduijm
  • hjsielcken
  • kaliber-owner
  • daveykropf
  • eecolor
  • pkuepers
  • larsvankleef