Strapi i18n relations

Hello everyone, does anyone know how I can make a query to filter by locale the localized registries related to non-localized collections?

This topic has been created from a Discord post (1239946698827108352) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

I’m not sure about the non-localized collections, but here’s an example query to filter by local (i18n) GET /your-model?_locale=en

With greater context, or examples, I may be able to assist with the “related to non-localized collections” portion of your question.

Hey Brodacious, i have the same context of this question:

it appears to be a common localizations issue

You should be able to add a non-localized relationship with an entity that uses localization, but I don’t think that the relationship field will be localized. This means the same related entities will be displayed across all localizations.

Maybe try:

  1. Go to the Strapi Admin panel.
  2. Navigate to Content-Types Builder under plugins section.
  3. Click on the content type you want to add a relationship to.
  4. Click on the Add New Field button.
  5. In the new screen, choose the “Relation” field type. Fill in the details of the relation:
    5.a Select the related collection type.
    5.b Select the type of the relation (one-to-one, one-to-many, many-to-one, or many-to-many).
  6. You can then save the relationship. If the entity is localized, the relationship field by default will not be localized - same related entities will be shown across all localizations.

Also, if you need to have different related entities per localization, I think you’ll need to handle it manually (e.g. using custom code you could hide or show relations depending on the current localization)