It isn't very clear what this option does. We ran into the issue when upgrading an existing site to the latest drupal 8: the views would display content in the source language rather than in their translation. As a workaround, we started changing the setting to "Content language selected for page".

We only found out, that the setting "Content language of view row" works if used together with the filter "Content: Translation language”. It would be great if there was some explanation on how the rendering language options work. If my assumptions are correct: If the "Content language of view row" option is set, it could also check for the "Content: Translation language" filter to exist and if not output a warning?

Comments

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

It isn't very clear what this filter does

Its not a filter. You already have your results when the rendering happens, it does not filter. It merely decides what language to use for the rendering as a primary target (and fall back from there if that is not available).

As a workaround, we started changing the setting to "Content language selected for page".

What was your original settings combination of filter/rendering?

Instead it is good with using the filter "Content: Translation language”. It would be great if there was some explanation on how the rendering language options work. If the "Content language of view row" it could also check for the "Content: Translation language" filter to exist and if not output a warning.

What should it warn you about? What did not work in your combination of configuration that you expected to work?

Gábor Hojtsy’s picture

Issue tags: +D8MI, +language-content, +VDC
Gábor Hojtsy’s picture

dasjo’s picture

Issue summary: View changes
dasjo’s picture

Sorry that wasn't very clear :) I updated the issue summary, makes more sense now?

Gábor Hojtsy’s picture

Title: Document views "Content language of view row" rendering language option » "Content language of view row" rendering option does not always ensure row language is present
Category: Task » Bug report
Status: Postponed (maintainer needs more info) » Active

So I retitled the issue to "Content language of view row" rendering option does not always ensure row language is present because that is how it sounds like. I believe this code is supposed to ensure that there is a langcode field proper in the query from the TranslationLanguageRenderer row plugin:

  public function query(QueryPluginBase $query, $relationship = NULL) {
    // There is no point in getting the language, in case the site is not
    // multilingual.
    if (!$this->languageManager->isMultilingual()) {
      return;
    }
    // If the data table is defined, we use the translation language as render
    // language, otherwise we fall back to the default entity language, which is
    // stored in the revision table for revisionable entity types.
    $langcode_key = $this->entityType->getKey('langcode');
    foreach (array('data_table', 'revision_table', 'base_table') as $key) {
      if ($table = $this->entityType->get($key)) {
        $table_alias = $query->ensureTable($table, $relationship);
        $this->langcodeAlias = $query->addField($table_alias, $langcode_key);
        break;
      }
    }
  }

Is this a node view? If not, does this entity have its data table, etc. defined so this logic will find it? In other words, is there a problem in this logic or in your entity definitions? :) This logic from the looks of it should ensure the row has the right language (if the entity had a data table), but will indeed render in the source language if the entity only had revisions but no data table or no revisions at all.

jhodgdon’s picture

I'm confused why this isn't still "postponed, maintainer needs more info" because it seems like we need more information about what kind of view this was?

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry I've been told over IRC that it was a node view, so the default logic should have worked. I asked for query debug info, so we can see what is in the query if the field is not there... So for that, this needs more info.

olli’s picture

jhodgdon’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I tested this today on the latest Drupal 8 code. What I did:

- Install with Standard profile in English.
- Turn on the 4 multilingual modules.
- Add Spanish language.
- Make Node translatable (both content types).
- Add an English Article node translated to Spanish, and a Spanish Page node
translated to English.

Then I made a view of nodes. I added a Page display that displays Teasers, and a Block view that displays fields (and I added the Title and Body fields to the view).

Both of them have the default "Content language of view row" rendering option under Languages. Neither of them has a language filter. Both of the displays work fine.

So, I am unable to reproduce this, and I am assuming that one of the many Views-related bugs we fixed in the past few months fixed this issue.

If the issue is still a problem, please change the status back to Active, and provide more information on how to reproduce the bug, such as an export of the view (which you can get from the Configuration Manager page under Export), and/or more information on how you made the view. Thanks!

jatinkumar1989’s picture

I am facing this issue after updating drupal core from 8.3.2 to 8.4.2.

Any solution ?

jhodgdon’s picture

Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)

Please see comment #10... If you make a view following those steps, do you see the same thing that I saw two years ago when I marked this issue "Cannot reproduce"? If not, see the last paragraph of #10 and please export the view, save it in a text file, and attach it here. And provide some explanation of how you reproduced the bug (content types, content in your system, languages, etc.). Thanks!

jhodgdon’s picture

Alternatively, if you decide that your problem is somewhat different from what is described in #10, then you might consider creating a new issue. If you do that, please describe the view and content types you created (export the view if possible), what you expected to see, and what you saw instead. Without clear steps to reproduce, it's very difficult to investigate, much less fix bugs. Thanks!

akupaka’s picture

Hello!
It seems that I'm facing this issue, or doing something wrong.

Drupal 8.4.2.
I have two language enabled: English (en) and Ukrainian (uk), Ukrainian is default for site.
I created one node with translation, uk - original, en - translation.
Content is displayed like it is supposed to: if uk is selected as interface language, then uk version is displayed, and if en is selected as interface language, then en version is displayed.

I made the view according to the user guide: https://www.drupal.org/docs/user_guide/en/views-create.html , and translated it.
Fields to display are Title and Body (both translatable). Filter criteria: published == yes, content type == My Content Type.

And here is what I get depending on Rendering Language:

  • Content language of view row: two rows, one for each language, en and uk, no matter which interface language is selected;
  • Original language of content in view row: two rows, both are in uk, no matter which interface language is selected (node's original is uk);
  • Site's default language (Ukrainian): two rows, both are in uk, no matter which interface language is selected (site's default is uk);
  • Interface text language selected for page: two rows, both are in selected interface language, as if en is selected, both rows are in en, if uk is selected, both rows are in uk;
  • Particular language selected, eg. Ukrainian/English: two rows, both are in selected language, eg. Ukrainian/English.

So it looks like it works... but not the way I expect =)
Could you please advice me what to check or configure? Thank you!

Addition:
if I add filter: "Content: Translation language (= Interface text language selected for page)" than view works as expected! So until I face other issue, I will consider this configuration as a workaround. Although there is no fall back to node's original language if it wasn't translated =(

akupaka’s picture

I have found another workaround here https://drupal.stackexchange.com/questions/192782/how-do-i-get-views-con...

  1. Add the "Default Translation" filter to a view. That basically ensures that all your nodes are shown once because each node can only have one default translation.
  2. Select "Interface text language selected for page" for "Rendering" language. That will attempt to display the site in the current language and fall back if that's not available. (Interface text sounds a bit misleading, but unless you explicitly enabled separate content language negotiation, that's the same as the content language).

It seems to work!

kle’s picture

Thanks akupaka - works perfectly !
Now I struggle with this: I let the nodetitle link to his content. But the Link-Builder builds the link dependant of the language - not depending on the active language, so if I click on an untranslated link I change my language to this ("original"-) language.

(but this belongs to https://www.drupal.org/project/drupal/issues/2802311)

akupaka’s picture

kle, I have the same trouble. Don't have any idea how to resolve this.
I'd like to have page opened as it is (untranslated), but not interface language changed.

Version: 8.0.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mlncn’s picture

Status: Postponed (maintainer needs more info) » Active

The workaround in #15 works, thank you akupaka!

But it feels like not quite the way we should have to do it, that we expect to do multilingual views in Drupal 8 and Drupal 9? Had to do this on a view listing taxonomy terms.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
portulaca’s picture

My example is with taxonomy term Relationship (the classic Taxonomy term node views), and I wanted to share what worked for me since it can be useful to others @mlncn

I couldn't get the Views to work with the "Default translation" (set to True) no matter what Rendering option was chosen. I would get duplicates in results, no matter what the interface language, and all node translations would display.

For me the winning combination is the "Content: Translation language (= Interface text language selected for page)", and after you add the taxonomy term Relationship "(field_tags: Taxonomy term) Taxonomy term: Translation language (= Interface text language selected for page)".

So I needed both of these when the Relationship is present. And also: "Rendering Language: Interface text language selected for page".

My use case is to only show content that is in the current Interface language, without fallbacks for content that don't have translations.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.