Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config parsing fails when i18n is set to duplicate #7332

Open
privatemaker opened this issue Nov 27, 2024 · 2 comments
Open

Config parsing fails when i18n is set to duplicate #7332

privatemaker opened this issue Nov 27, 2024 · 2 comments
Labels
type: bug code to address defects in shipped code

Comments

@privatemaker
Copy link
Contributor

privatemaker commented Nov 27, 2024

Describe the bug

As per #7291 upon recently trying to configure a i18n site with the new i18n: duplicate value on a per-field basis as per the i18n Documentation, I discovered it causes my config to fail to parse.

Expected behavior

Setting i18n: duplicate should not cause config to fail to parse and should duplicate fields in a read-only fashion in the cloned page.

Screenshots

390036025-dd39c504-82e3-446e-9a82-822f81e11c9f

Applicable Versions:

  • Decap CMS version: decap-cms 3.4.0
  • Git provider: GitLab
  • OS: Linux
  • Browser version Firefox 115.14
  • Site generator: Hugo
  • Decap Setup: Hugo Module headless-cms

CMS configuration

  locale: "en"
  i18n:
    structure: multiple_files
    locales: [en, de]
    default_locale: en
  slug:
    encoding: "ascii"
    clean_accents: true
    sanitize_replacement: "-"
  collections:
    - name: "blog"
      label: "Blog"
      label_singular: "Blog"
      folder: "content/blog"
      path: "{{slug}}"
      widget: "list"
      create: true
      i18n: true
      editor:
        preview: true
      preview_path: "blog/{{slug}}"
      media_folder: '/static/uploads'
      public_folder: '/uploads'
      fields:
        - label: "Title"
          name: "title"
          widget: "string"
          i18n: true
        - label: "Draft"
          name: "draft"
          widget: "boolean"
          default: true
          i18n: true
        - label: "Image"
          name: "banner"
          widget: "image"
          required: false
          default: "/uploads/placeholder.jpg"
          choose_url: true
          media_folder: '/static/uploads'
          public_folder: '/uploads'
          i18n: true

If I change any of the i18n: true values in the fields to i18n: duplicate I get the broken config parsing error shown above.

@privatemaker privatemaker added the type: bug code to address defects in shipped code label Nov 27, 2024
@martinjagodic
Copy link
Member

@privatemaker it seems that the problem is with the widget list. This one does not support i18n: duplicate. Itself and all its children should thus have i18n: true.

This is mentioned in docs like this:

List widgets only support i18n: true. i18n configuration on sub fields is ignored.

I would say that the docs are ok, but we could improve the error message.

@privatemaker
Copy link
Contributor Author

Thanks for investigating. I did get it working by trial and error of eliminating all instances of it and slow re-adding on different fields. But this is a bit random and wacky.

So, I think the docs could be improved a bit and will send a pull-request 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants