Happy Coder
Happy Coder

Reputation: 4692

How to Display Translated Content by Language in Drupal Views?

Title: How to Display Translated Content by Language in Drupal Views?

I have a View in Drupal with multiple displays, each configured as follows:

Display 1: Articles

Display 2: Page

Display 3: A-F

The first display, "Articles," with the path /articles/insights, shows the article listing, while the second, third, and other similar displays show the Glossary of articles. The Page Category is a field called field_page_category, which can be selected when adding an article.

Now, I have some articles that are translated into Portuguese-Brazil (pt-br) and have the page category as Glossary. I want to display these links when I access /pt-br/articles/glossary. I tried creating a new display for the View with the path /pt-br/articles/glossary, and in the filter criteria, I added:

However, it still displays all the links in English. I'm unable to find a Language filter when attempting to add it.

The SQL query I received is:

SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "node__field_subtitle"."field_subtitle_value" AS "node__field_subtitle_field_subtitle_value", "node_field_data"."nid" AS "nid"
FROM
{node_field_data} "node_field_data"
INNER JOIN {node__field_page_category} "node__field_page_category" ON node_field_data.nid = node__field_page_category.entity_id AND node__field_page_category.deleted = '0'
INNER JOIN {node_field_revision} "node_field_revision" ON node_field_data.vid = node_field_revision.vid
LEFT JOIN {node__field_subtitle} "node__field_subtitle" ON node_field_data.nid = node__field_subtitle.entity_id AND (node__field_subtitle.deleted = '0' AND node__field_subtitle.langcode = node_field_data.langcode)
WHERE ((node__field_page_category.field_page_category_value = 'Glossary')) AND (("node_field_data"."status" = '1') AND ("node_field_data"."type" IN ('article')) AND ("node_field_data"."langcode" IN ('pt-br')) AND ("node_field_revision"."langcode" IN ('pt-br')))
ORDER BY "node__field_subtitle_field_subtitle_value" ASC

How can I configure Drupal Views to display content in Portuguese (pt-br) when accessing the /pt-br/articles/glossary URL? I can't seem to find the Language filter to achieve this.

The language filters I already have are as follows:

Title Category
Delivery Language Content
Original language Content
Translation language Content
Translation source Content
Original language Content revision
Original language Content revision
Translation language Content revision
Translation source Content revision

Upvotes: 1

Views: 198

Answers (1)

Emircan ERKUL
Emircan ERKUL

Reputation: 41

Happy Coder

Instead of these filters, could you add Content: Default translation filter and select true? and in the Rendering Language select Interface text language selected for page.

Regards,

Upvotes: 0

Related Questions