question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content Relationship and Multi-languages: Wrong type for custom types

See original GitHub issue

Setup:

  • “prismic-javascript”: “^1.1.5”,
  • Two custom types (home_page and tip). tip is used in a slice of home_page
  • Master language is de-ch and a 2nd language fr-ch

If I query the master language the custom types in slice.items is correct ("type": "tip",)

JS:

  const client = await Prismic.api(`https://${repositoryName}.prismic.io/api/v2`, { accessToken })
  const response = await client.query("", {lang: "de-ch"})

Result

{
  "id": "XKXobhAAAJmVNCNu",
  "type": "home_page",
  "lang": "de-ch",
  "data": {
     ...
    "body": [
      {
        "slice_type": "content",
        "items": [
          {
            "tip": {
              "id": "XKbxCxMAACIAP_bb",
              "type": "tip",
              "lang": "de-ch"
            }
          }
        ]
      }
    ]
  }
}

But when I query a non-master language I get "type": "home_page", as type for the custom type

JS:

  const client = await Prismic.api(`https://${repositoryName}.prismic.io/api/v2`, { accessToken })
  const response = await client.query("", {lang: "fr-ch"})

Result

    {
      "id": "XKXzwxAAAByKNFXn",
      "type": "home_page",
      "lang": "fr-ch",
      "data": {
       ...
        "body": [
          {
            "slice_type": "content",
            "slice_label": null,
            "items": [
              {
                "tip": {
                  "type": "home_page",
                  "lang": "fr-ch",
                 }
              }
            ]}
        ]
      }
    },

Any idea why?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
arnaudlewiscommented, Apr 5, 2019

The issue was identified and it’s related to the translation from one locale to another. We already released a fix to prevent that from happening again and another fix will be released on Monday for already corrupted links. Sorry for the inconvenience.

Le ven. 5 avr. 2019 à 18:07, Marcel Eyer notifications@github.com a écrit :

Actually it looks like its a general problem of the API. I did a dummy repo to test.

While the master language returns the right (chi) type for results.[type=“paren”]. data.child.type the 2nd language does not.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/prismicio/prismic-javascript/issues/86#issuecomment-480332412, or mute the thread https://github.com/notifications/unsubscribe-auth/AFtiX2stpsYKroUdTVgBafbrK426i6eEks5vd3TagaJpZM4ce7M1 .

1reaction
arnaudlewiscommented, Apr 8, 2019

The fix is coming today to resolve this issue. I’ll keepyou posted 😉

Le lun. 8 avr. 2019 à 11:46, Marcel Eyer notifications@github.com a écrit :

Hi @arnaudlewis https://github.com/arnaudlewis

There is still similar bug with i18n and custom types. Looks like its related to the Single Type custom type:

master language: https://broken-content.prismic.io/api/v1/documents/search?ref=XKsVyRMAAEqPUjE1#format=json

oah: { type: “Link.document” value: { document: { id: “XKsRthMAAO6UUh79” type: “child” tags: [ ] lang: “en-us” slug: “child-title-en” }

2nd language (document object is missing): https://broken-content.prismic.io/api/v1/documents/search?ref=XKsVyRMAAEqPUjE1&lang=de-ch#format=json

{ oah: { type: “Link.document” value: “=&=033XKsR0hMAAO6UUh96%%parent-single%%” } }

Or do I something wrong?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/prismicio/prismic-javascript/issues/86#issuecomment-480762458, or mute the thread https://github.com/notifications/unsubscribe-auth/AFtiXxAtOdSnMwnPRHJGkx_gEeIJkerGks5vew_sgaJpZM4ce7M1 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with WPML and Pods Templates since 2.8 | WordPress.org
-I'm using WPML to create a multi-language website. -I create two different Custom Post Types with Pods 2.8.1. -I create a bidirectional relationship...
Read more >
Best Practices and Considerations for Multilingual Sites
Keep these practices and considerations in mind when you're setting up a multilingual site.Required Editions Available in: Experience Builder sites access.
Read more >
How can I rewrite custom post types slugs based on language?
Important: Flushing the rewrite rules is an expensive operation, there are tutorials and examples that suggest executing it on the 'init' hook. This...
Read more >
Support different languages and cultures - Android Developers
Some users choose a language that uses right-to-left (RTL) scripts, such as Arabic or Hebrew, for their UI locale. Other users view or...
Read more >
Multilanguage text - Adobe Support
Use this guide to understand how to work with Multilanguage text in Animate.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found