4.0.0 • Published 2 months ago

@kaliber/sanity-plugin-multi-language v4.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

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

npm.io

4.0.0

2 months ago

2.2.0-beta1

2 months ago

2.2.0

2 months ago

3.2.0

3 months ago

3.1.0

6 months ago

3.0.0

8 months ago

2.0.2

9 months ago

2.0.1-beta.0

10 months ago

2.0.1-beta.1

10 months ago

2.1.0

9 months ago

2.0.1

10 months ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.0.1

3 years ago