decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.7k stars 3.03k forks source link

i18n duplicated fields are not actually duplicated but removed #6978

Open Billybobbonnet opened 8 months ago

Billybobbonnet commented 8 months ago

I have a collection with some fields to be translated (i.e. i18n:true ), and some that should not. It turns out that when the document is saved, all the duplicated fields are stripped from the translated document.

I assume this is not the intended behaviour and it makes this function unuseable.

FYI my provider is Github. Files are markdown.

Here is the actual example of collection config that triggers this behaviour:

collections:
  - name: 'jury'
    label: 'Jury'
    label_singular: 'Jury member'
    i18n: true
    view_filters:
      - label: '2021 Edition'
        field: edition
        pattern: '2021'
      - label: '2024 Edition'
        field: edition
        pattern: '2024'
    nested:
      depth: 2
      summary: '{{lastname}} {{firstname}}'
    folder: 'content/jury' # The path to the folder where the documents are stored
    create: true
    summary: '{{lastname}} {{firstname}}'
    slug: '{{lastname}}-{{firstname}}'
    fields:
      [
        {
          label: Firstname,
          name: firstname,
          widget: string,
          default: '',
          required: true,
          i18n: duplicate,
        },
        {
          label: 'Edition(s)',
          name: 'editions',
          widget: 'select',
          default: ['2024'],
          multiple: true,
          options: ['2021', '2024'],
          i18n: duplicate,
          min: 1,
        },
        {
          label: Lastname,
          name: lastname,
          widget: string,
          default: '',
          required: true,
          i18n: duplicate,
        },
        {
          label: 'Body',
          i18n: true,
          name: 'body',
          widget: 'markdown',
          required: false,
          hint: 'Use it to store the bibliography',
        },

        {
          label: Title and institution,
          name: title_and_institution,
          widget: string,
          default: '',
          required: false,
          i18n: true,
        },
        {
          label: Presentation,
          name: presentation,
          widget: text,
          default: '',
          required: true,
          i18n: true,
        },
        {
          label: 'Image',
          name: 'image',
          widget: 'image',
          required: false,
          i18n: duplicate,
        },
        {
          label: 'Picture Copyright',
          name: 'copyright',
          widget: 'string',
          required: false,
          i18n: duplicate,
        },
        {
          widget: 'object',
          default: [],
          collapsed: true,
          label: 'Social channels',
          name: 'social_channels',
          i18n: true,
          fields:
            [
              {
                label: 'Website',
                name: 'website',
                widget: 'string',
                default: '',
                required: false,
                i18n: duplicate,
              },
              {
                label: 'Wikipedia',
                name: 'wikipedia',
                widget: 'string',
                default: '',
                required: false,
                i18n: duplicate,
              },
            ],
        },
      ]