Skip to content

i18n plugin upgrade #3664

Description

@padms

Sanity document internationalization plugin has a newer version and is available along with sanity package.

  • Since this upgrade requires migration, consider changing the value of language field to have iso name. For example en-GB instead of en_GB, to avoid complexity with locale in the web. This below language configuration can be removed for each language, and the Intl namespace from Javascript can be used to get the title, locale etc. The reason why we could not use Intl is because of en_GB which is not a standard to describe a language.
    { id: 'norwegian',
    title: 'Norwegian',
    iso: 'nb-NO',
    name: 'nb_NO',  
    locale: 'no',
    },
    
    

It has some useful features like

  • Allowing one to create the metadata document, without creating a duplicate translated version. Useful in cases where we have to link already existing documents.
       // Enable "manage translations" button without creating a translated version. Helpful if you have
       // pre-existing documents that you need to tie together through the metadata document
       allowCreateMetaDoc: true, // defaults to false
    
    
  • Hide the language button on top of document. Useful with poland site as the button is of no use for a site with single langauge.
      // Hides the language filter (Translations button) in the document editor toolbar.
      // The language badge will still be shown. Accepts:
      // - A boolean to hide for all types: `hideLanguageFilter: true`
      // - An array of schema type names: `hideLanguageFilter: ['lesson']`
      // - A function for dynamic control: `hideLanguageFilter: (ctx) => ctx.schemaType === 'lesson'`
      hideLanguageFilter: true, // defaults to false
    }
    
  • Duplicate with translations action, to duplicate a version along with its translated versions.
  • Options to exclude fields from getting copied to the translated version. When creating a norwegian news from a published english news, we can potentially exclude the firstPublishedAt, lastModifiedAt and send to subscribers values from the english versions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions