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

i18n: support "duplicate" setting on list fields #4386

Open
cbix opened this issue Sep 29, 2020 · 9 comments
Open

i18n: support "duplicate" setting on list fields #4386

cbix opened this issue Sep 29, 2020 · 9 comments
Labels
area: extensions/widgets area: i18n pinned type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@cbix
Copy link

cbix commented Sep 29, 2020

Currently, list fields only support i18n: true and i18n: false. For many cases (like a picture carousel) the content needs to be the same among all locales, where i18n: duplicate would make sense.

Possible workarounds are using a relation widget and storing the content in a separate collection or setting i18n: false and fetching it from the default locale manually. This is less intuitive for either the editors or the developer.

@cbix cbix added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Sep 29, 2020
@erezrokah
Copy link
Contributor

erezrokah commented Sep 29, 2020

The challenge here was to mirror the widget behaviour in the side by side editor, so it was postponed as a part of the original PR.

@cbix
Copy link
Author

cbix commented Sep 30, 2020

I just realized that even other widgets are not storing anything in my frontmatter with i18n: duplicate so I need to deal with fetching data from the default locale anyway.
Which makes this purely a netlify-cms frontend issue.

@barthc
Copy link
Contributor

barthc commented Sep 30, 2020

I just realized that even other widgets are not storing anything in my frontmatter with i18n: duplicate

The duplicate flag should work for other widgets, can you show your config?

@cbix
Copy link
Author

cbix commented Sep 30, 2020

@barthc Ah, you're right, it does work. I probably messed something up by changing a field form i18n: false to i18n: duplicate and of course the field didn't magically get added in the translated markdown file ;)

@cbix
Copy link
Author

cbix commented Sep 30, 2020

@barthc Ok I figured out the hidden widget doesn't work with i18n: duplicate which is kinda crucial for my case to work because editors are supposed to create pages in different collections that get built using different templates.
Versions are netlify-cms-app 2.12.24 and netlify-cms-core 2.30.7 and I'm testing with netlify-cms-proxy-server.

My config.yml:

...
i18n:
  structure: multiple_files
  locales: [en, de]
  default_locale: en

collections:
  - name: content-pages
    label: Content Pages
    folder: content/pages
    create: true
    i18n: true
    fields:
      - {label: Template Key, name: templateKey, widget: hidden, default: content-page, i18n: duplicate}
      - {label: Title, name: title, widget: string, i18n: true}
      - {label: Image, name: image, widget: image, i18n: duplicate, required: false}
      - {label: Body, name: body, widget: markdown, i18n: true}

After creating a new page in netlify-cms, I get two new markdown files in content/pages.
test.en.md:

---
templateKey: content-page
title: test
image: /img/test.png
---
test body

and test.de.md:

---
title: testfoo
image: /img/test.png
---
test inhalt

In my previous test I had a collection with create: false and manually set the templateKey field for development.
Edit: this might be #4356

@blackb1rd
Copy link
Contributor

blackb1rd commented Oct 1, 2020

It's a same issue as #4356

Workaround is to change hidden widget to string widget and also remove default settings value. Then input "content-page" into the string widget.

@khawarizmus
Copy link

Any timeline for this feature?

@erezrokah
Copy link
Contributor

Any timeline for this feature?

The best way to move this forward is to submit a PR for it @gimyboya

@michaelmannucci
Copy link

Any progress here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/widgets area: i18n pinned type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

7 participants