1

Let say I have a content type with 2 fields that can be translated in a 2 languages site (EN-FR): the title and field_tobe_translated

I would like to list (in a view) all nodes of this content type with only one row by node and each row should have this format:

Title_FR -- Title_EN -- translatable_field_FR -- translatable_field_EN

The "--" before means a column separator in a table type view.

Added question:

Is it possible to filter this view to show only the row where "Title_FR != Title_EN" [I assusme that the process would be the same for the other translatable field]

1

I haven't found a way to show translations in the same row as the source, without additional modules that is. Although that would be nice to have.

These modules aren't currently covered by Drupal’s security advisory policy so they might not be a wise choice:

A compromise might be to show your information spread accross two rows instead of one:

  1. Create Views showing Title and Field for the two languages
  2. Sort by ID (this will list translations close to their sources so you'll end up with pairs of English and French nodes that are translations of the same content)
  3. Add another Sort criteria by Language (this way you're sorting inside each pair, so you always get French first, English second, if that's how you prefer it)

So in the end you'd have:

+----+------------+-------------------------+
| ID | Title | Field |
+----+------------+-------------------------+
| 1 | Title_FR_1 | translatable_field_FR_1 |
+----+------------+-------------------------+
| 1 | Title_EN_1 | translatable_field_EN_1 |
+----+------------+-------------------------+
| 2 | Title_FR_2 | translatable_field_FR_2 |
+----+------------+-------------------------+
| 2 | Title_EN_2 | translatable_field_EN_2 |
+----+------------+-------------------------+
| 3 | Title_FR_3 | translatable_field_FR_3 |
+----+------------+-------------------------+
| 3 | Title_EN_3 | translatable_field_EN_3 |
+----+------------+-------------------------+

  • Many thanks for this nice idea... If one of the module you are listing can answer this question, I will set it as answered. – Baud May 15 '18 at 9:42
  • Follow up: I didn't find a way to answer this question with "Translation Views" and "Views entity translation shorcuts", but maybe I missed something. I gaved a try to "Translate Side by Side" but the module is unusable (I filled a bug report)... wait and see... – Baud May 16 '18 at 8:59
  • I haven't yet figured it out, need to investigate further, or someone more knowledgeable comes along. – prkos May 16 '18 at 19:33
0

I knew there was a way, even if it's the old way (I expected it would be possible in D8 out of the box).

Use Views Field View module

You can do it with the help of Views Field View. It's basically embedding a View into another View to be displayed as a field.

You have to have the Child View created before you can add it to the Parent Views. Parent and Child can be two Displays on the same Views, they don't have to be in two different Views.

In your case your Child View will be filtered to show only fields related to one node (using regular and Contextual Filters), so you can end up with a nicely styled result where one node information is displayed in one table row.

  1. Create a Views Display of type Embed to serve as your Child Display.
  2. Filter it to list your content and also add the Filter Content: Translation language and set it to French (Or English)
  3. Add Title and the other field you want to see
  4. Format Unformatted list and under Fields Settings set both fields as Inline, separator may be something like |
  5. Add a Contextual Filter Content: ID and configure it to:
    When the filter value is NOT available
    Provide default value
    Content ID from URL
    (Optionally specify validation criteria)
  6. Create a Page view (you probably have this already) of Table Format
  7. Filter it to list your content and also add the Filter Content: Translation language and set it to English (Or French, the opposite from the one which you set in Step 2)
  8. Add a Field Content: ID and Exclude it from display. This info will be fed to the Embedded view to filter only translations for that node
  9. Add the Title and the other field you need to show
  10. Add the field Global: View and under View settings select the View name from the first dropdown
  11. Apply
  12. Save the View
  13. Edit the Global: View again, this time you'll be able to choose the exact Views Display you created in step 1
  14. In the Contextual filters enter {{ raw_fields.nid }} or whatever makes sense in your case, check under Replacement patterns

You should now see the list of nodes with English and French fields on the same row.

The Inline fields might not emulate the Table cell look exactly. You can make this display as table cells exactly with some more elaborate HTML overwrites to make them blend together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.