contentful_middleman: Entities and assets don't get linked when using multiple locales

If I add locales: '*' to the CDA query, assets and links will only show the sys key and won’t be populated with the actual linked resource. In the following example, I’m using two locales (en-us and fr-CA) and two content types: a Section that contains multiple _Topic_s

Here’s the generated yml I get for a Section if I don’t specify multiple locales in the CDA query (f.cda_query = {}):


---
:id: 1RU28gignOCGg0UMau0mcM
:title: Life
:topics:
- :id: 5Hf7MhcNaw4OWoAWKYWa6M
  :question: Why?
  :answer: Because

💯 . The associated _Topic_s are populated.

Here is what I get when I set f.cda_query = { locales: '*' }:


---
:id: 1RU28gignOCGg0UMau0mcM
:title:
  :en-US: Life
  :fr-CA: La vie
:topics:
  :en-US:
  - sys:
      type: Link
      linkType: Entry
      id: 5Hf7MhcNaw4OWoAWKYWa6M

It loads plain fields just fine (the title), but linked entries are no longer populated.

For reference, here’s what one of the Topic yml files looks like:


---
:id: 1RU28gignOCGg0UMau0mcM
:title:
  :en-US: Life
  :fr-CA: La vie
:topics:
- :id: 5Hf7MhcNaw4OWoAWKYWa6M
  :en-US:
    :question: Why?
    :answer: Because
  :fr-CA:
    :question: Pourquoi?
    :answer: Parce que

It’s not shown in the above example, but the same issue happens with linked assets.

Additional information

  • Ruby 2.2.3
  • Middleman 3.4.1
  • Latest published contentful_middleman (also tried with both contentful.rb and this repo’s master)
  • Tried with these two content type settings:
    • i18n enabled on the Section “topics” one-to-many reference field and i18n disabled on the Topic fields (question and answer)
    • i18n disabled on the “topics” reference but enabled on Topic’s fields.

Any idea how to solve this? Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

Issue is still persistent on assets that are localized (entries now work fine).

Fix was found and currently adding specs around the feature.

New version will be published within the next few hours or early tomorrow.

cc @frankmarineau @martzoukos

@frankmarineau Looking into it early tomorrow.

Hey @martzoukos,

Sadly Assets are not regular entries, so they use a different API endpoint.

I will try to get this solved between today and tomorrow, and release a new version with the fix early next week.

Hope that helps