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

Multisite Taxonomy Terms Field on a Taxonomy does not get translated when fetched with GraphQl #9469

Closed
Kylewalow opened this issue Feb 6, 2024 · 0 comments · Fixed by #9492

Comments

@Kylewalow
Copy link

Bug description

We have a Taxonomy named "Topics". It contains a text field "title" and a Taxonomy Terms field "topic_area" (a taxonomy linked to a taxonomy).

We use the "topic_area" field to group the topics for a filter in our frontend.

Both Taxonomies exist in multiple languages: DE, FR, IT.

Correct

This is the query to fetch the topics in DE:

query MyQuery {
  terms(taxonomy: "topics", filter: {site: {is: "de"}}) {
    data {
      ... on Term_Topics_Topic {
        slug
        title
        topic_area {
          title
          slug
        }
      }
    }
  }
}

Correct result:

{
  "data": {
    "terms": {
      "data": [
        {
          "slug": "abfall",
          "title": "Abfall",
          "topic_area": {
            "title": "Umwelt",
            "slug": "umwelt",
          }
        }
      ]
    }
  }
}

Incorrect

When filtered by e.g. FR language

query MyQuery {
  terms(taxonomy: "topics", filter: {site: {is: "fr"}}) {
    data {
      ... on Term_Topics_Topic {
        slug
        title
        topic_area {
          title
          slug
        }
      }
    }
  }
}
{
  "data": {
    "terms": {
      "data": [
        {
          "slug": "abfall",
          "title": "Déchets",
          "topic_area": {
            "title": "Umwelt",
            "slug": "umwelt",
          }
        }
      ]
    }
  }
}

Expected

The topic itself gets correctly translated but not the topic area linked to it, even though the topic area has its localized data defined.
Correct would be:

  "topic_area": {
    "title": "Environnement",
    "slug": "umwelt",
  }

To mention

I tried to translate the slugs of the topic_area as well, but upon saving, a Topic always saves the 'DE' slug of the topic_area regardless of the language. I'm not sure if this is causing the behavior:

title: Abfall
topic_area: umwelt
updated_by: df6eb467-9bfd-4972-ba55-21428e1f1454
updated_at: 1705573702
blueprint: topic
localizations:
  fr:
    title: Déchets
    topic_area: umwelt  <- This slug stays on default language even if the slug in the "FR" version is defined as "environnement".
    slug: abfall
    updated_by: df6eb467-9bfd-4972-ba55-21428e1f1454
    updated_at: 1707236200

How to reproduce

  1. Start a Statamic Multisite Project.
  2. Create a Taxonomy for all languages.
  3. Create a second Taxonomy for all languages.
  4. Link the second Taxonomy to the first with a Taxonomy Terms field. This establishes a relationship between the two taxonomies, allowing terms from the second taxonomy to be associated with terms from the first.
  5. Add a Term for both taxonomies (test content) in all languages. Ensure that you provide translations for these terms in all the languages supported by your multisite setup.
  6. In the term of the first taxonomy, link the term of the second taxonomy with the Taxonomy Terms field. This step involves selecting a term from the second taxonomy to associate with a term from the first taxonomy.
  7. Save your changes.
  8. Open the GraphQL Editor (make sure to enable the GraphQL API and allow the created taxonomies). This involves configuring your Statamic settings to ensure that GraphQL is enabled and that the newly created taxonomies are accessible via the GraphQL API.
  9. Use the query from the "Bug description" but replace the names so that it matches with the created Taxonomies and languages.
  10. Now filter by site, and you will see that the linked taxonomy doesn't get translated. This indicates that while the primary taxonomy term translates according to the site language, the linked taxonomy term does not, retaining its default language instead.

Logs

No response

Environment

Environment
Application Name: STV
Laravel Version: 9.52.16
PHP Version: 8.2.13
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: stv-cms.novu.io
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: mysql
Logs: single
Mail: smtp
Queue: redis
Session: redis

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 3.8.2
PHP SDK Version: 3.22.1
Release: e8900f52c
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: 0%
Sample Rate Profiling: NOT SET
Send Default PII: ENABLED

Statamic
Addons: 4
Antlers: regex
Stache Watcher: Disabled
Static Caching: Disabled
Version: 4.40.0.2 PRO

Statamic Addons
aryehraber/statamic-uuid: 2.2.0
rias/statamic-redirect: 2.x-dev
roorda-ict/statamic-entries-export: 2.1.0
teamnovu/statamic-images-missing-alt: 1.0.2

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

None

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants