Skip to content

i18n: duplicate on list widget returns an error #4888

@scerelli

Description

@scerelli

Describe the bug
Can't assign to list widget i18n: duplicate

To Reproduce

  • create a new config with i18n enabled
  • put a list in your collection and add i18n: duplicate
  • you get an error: 'collections[0].fields[9].i18n' should be boolean
    sample code:
i18n:
  structure: multiple_files
  locales: [en, de]
  default_locale: en
slug:
  encoding: "ascii"
  clean_accents: true
  sanitize_replacement: "_"
collections:
  - name: 'projects'
    label: 'Projects'
    folder: "src/pages/projects"
    create: true
    delete: true
    i18n: true
    slug: '{{title}}'
    fields:
      - { label: "Gallery", name: "galleryImages", i18n: duplicate, widget: "list", summary: '{{fields.image}}', field: {label: Image, name: image, widget: image }}`

Expected behavior
I expected the duplicated list to appear on the second language preview and to not return any error

Applicable Versions:

  • Netlify CMS version: [e.g. 2.0.4]
  • Git provider: Github
  • OS: OSX
  • Browser version Firefox 85

my deps

"dependencies": {
    "bulma": "^0.9.1",
    "gatsby": "^2.31.1",
    "gatsby-cli": "^2.18.0",
    "gatsby-image": "^2.10.0",
    "gatsby-plugin-netlify": "^2.10.0",
    "gatsby-plugin-netlify-cms": "^4.9.0",
    "gatsby-plugin-postcss": "^3.6.0",
    "gatsby-plugin-purgecss": "^5.0.0",
    "gatsby-plugin-react-helmet": "^3.9.0",
    "gatsby-plugin-sharp": "^2.13.1",
    "gatsby-remark-copy-linked-files": "^2.9.0",
    "gatsby-remark-images": "^3.10.0",
    "gatsby-remark-relative-images": "^2.0.2",
    "gatsby-source-filesystem": "^2.10.0",
    "gatsby-transformer-remark": "^2.15.0",
    "gatsby-transformer-sharp": "^2.11.0",
    "lodash": "^4.17.20",
    "lodash-webpack-plugin": "^0.11.6",
    "netlify-cms-app": "^2.14.14",
    "netlify-cms-media-library-cloudinary": "^1.3.8",
    "netlify-cms-media-library-uploadcare": "^0.5.9",
    "postcss": "^8.2.4",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "uuid": "^8.3.2"
  }

CMS configuration

backend:
  name: git-gateway
  branch: master
  commit_messages:
    create: 'Create {{collection}} “{{slug}}”'
    update: 'Update {{collection}} “{{slug}}”'
    delete: 'Delete {{collection}} “{{slug}}”'
    uploadMedia: '[skip ci] Upload “{{path}}”'
    deleteMedia: '[skip ci] Delete “{{path}}”'

media_folder: static/img
public_folder: /img
i18n:
  # Required and can be one of multiple_folders, multiple_files or single_file
  # multiple_folders - persists files in `<folder>/<locale>/<slug>.<extension>`
  # multiple_files - persists files in `<folder>/<slug>.<locale>.<extension>`
  # single_file - persists a single file in `<folder>/<slug>.<extension>`
  structure: multiple_files

  # Required - a list of locales to show in the editor UI
  locales: [en, de]

  # Optional, defaults to the first item in locales.
  # The locale to be used for fields validation and as a baseline for the entry.
  default_locale: en
slug:
  encoding: "ascii"
  clean_accents: true
  sanitize_replacement: "_"
collections:
  - name: 'projects'
    label: 'Projects'
    folder: "src/pages/projects"
    create: true
    delete: true
    i18n: true
    slug: '{{title}}'
    fields:
      - { label: "Template Key", name: "templateKey", widget: "hidden", default: "project-page", i18n: duplicate }
      - { label: 'Title', name: 'title', widget: 'string', i18n: duplicate }
      - { label: 'SEO Title', name: 'seoTitle', widget: 'string', i18n: duplicate }
      - { label: 'Description', name: 'description', widget: 'markdown', i18n: true }
      - { label: 'SEO Description', name: 'seoDesc', widget: 'string', i18n: duplicate }
      - { label: 'Exhibition name', name: 'exhibitionName', widget: 'string', i18n: duplicate }
      - { label: 'Exhibition location', name: 'exhibitionLocation', widget: 'string', i18n: duplicate }
      - { label: Image, name: image, widget: image, i18n: duplicate }
      - { label: Vertical image, name: verticalImage, widget: image, i18n: duplicate }
      - { label: "Gallery", name: "galleryImages", i18n: duplicate, widget: "list", summary: '{{fields.image}}', field: {label: Image, name: image, widget: image }}

  - name: "pages"
    label: "Pages"
    files:
      - file: "src/pages/index.md"
        label: "Home Page"
        name: "index"
        fields:
          - { label: "Template Key", name: "templateKey", widget: "hidden", default: "index-page" }
          - { label: Seo Title, name: seoTitle, widget: string }
          - {
            label: 'Projects',
            name: 'linkedProjects',
            identifier_field: 'title',
            widget: 'list',
            field: {
              label: "Project",
              name: "projects",
              widget: "relation",
              collection: "projects",
              search_fields: ["title", "seoTitle"],
              value_field: "slug",
              display_fields: ["title"]
            }
          }

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions