Note: This is part of the "Multilingual Views" meta-issue: #2313159: [meta] Make multilingual views work

Background: Rows in Node views are node translations. The Front Page default view config from the Node module was changed recently so that by default, it filters to show only translations in the currently-negotiated content language. The Content Admin default view config has an exposed filter for languages, and by default it shows all translations in all languages, which is appropriate for that view.

Current problem: The other provided default views of nodes do not have language filters. They should be filtering to what is currently-named in Views UI "User's current language", which really means "selected language of type 'Content'; the UI should soon be changed, see #2037979: "Current user's language" views filter label is named very misleading

This applies to:
- views.view.archive.yml - "Archive" (in core/modules/node/config/install)
- views.view.glossary.yml - "Glossary" (in core/modules/node/config/install)
- views.view.content_recent.yml - "Recent content" (in core/modules/node/config/install)
- views.view.taxonomy_term.yml - "Taxonomy term" (in core/modules/taxonomy/config/install)

Here are the steps to follow, for each applicable view. Note that at the moment, you'll need to have the Language module installed/enabled, in order to follow these steps:

a) Edit the view in the Views UI.
b) Add a filter for language to the Master display, and to any other displays that have custom filters. This filter is labeled "Content translation language" in the Views UI.
c) Save the view.
d) Verify that the view still works.
e) Export the view configuration using the config UI, and overwrite the file in the appropriate config/install directory.
f) Remove the UUID lines from exported config.

And the final step, once you've done the above for each views config:

Make a patch for these files that updates the config, and upload it here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

gauravkhambhala’s picture

Assigned: Unassigned » gauravkhambhala
gauravkhambhala’s picture

FileSize
11.09 KB

@jhodgdon Please review the patch. I have selected "Default site language" in the filter. Let me know if that needs to be changed.

gauravkhambhala’s picture

Status: Active » Needs review
jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Needs work

Thanks for the patch!

One small change -- see issue summary:

They should be filtering to what is currently-named in Views UI "User's current language", which really means "selected language of type 'Content'; the UI should soon be changed, see #2037979: "Current user's language" views filter label is named very misleading

So we do not want them filtered to 'site default language', but instead to "User's current language".

gauravkhambhala’s picture

Status: Needs work » Needs review
FileSize
11.18 KB

Thanks for the review. Updated patch.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Excellent, thanks!

As a note: these views also have the 'field_langcode' display option set on them, which is the setting that governs the display language for fields. It is just set to its default value. That should not affect anything.

So, I manually looked at this patch, and everything added/removed to the views configs looks right to me.

I also went to simplytest.me and installed Drupal with standard profile with this patch. I looked at these 4 default views as installed (in English). They all worked fine. I then enabled Language/Content Translation, added Spanish, translated my node, and tested. They all filtered to the currently selected language (I tested with /es/ before the URLs and without).

So, everything worked fine except for the taxonomy term view. It has a fatal error. That is true without this patch also though, so I'll file a separate issue.

Meanwhile, this patch is RTBC.

jhodgdon’s picture

jhodgdon’s picture

As a note, if #2037979: "Current user's language" views filter label is named very misleading goes in before this issue, we will need to update this patch, because the machine name of the filter value will not be ***CURRENT_LANGUAGE*** but language_content. So that will need to be search-and-replaced everywhere in this patch. I added a note to the other issue too. Just depends on which patch goes in first; set the other one to "needs work".

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/node/config/install/views.view.archive.yml
@@ -104,6 +113,49 @@
+          dependencies:
+            module:
+              - views
+              - views

+++ b/core/modules/node/config/install/views.view.content_recent.yml
@@ -402,6 +413,49 @@
+          dependencies:
+            module:
+              - views
+              - views

+++ b/core/modules/node/config/install/views.view.glossary.yml
@@ -301,6 +310,52 @@
+          dependencies:
+            module:
+              - views
+              - views

+++ b/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml
@@ -159,6 +168,49 @@
+          dependencies:
+            module:
+              - views
+              - views

This looks super weird - multiple dependencies on the same module should be impossible. This either is bug or something has gone wrong.

jhodgdon’s picture

That is a bug in Views. This is an export of a view. I've seen this before.

jhodgdon’s picture

OK... discussed this with Alex in IRC.

Could someone make a quick edit of this and remove those duplicate "dependencies" lines? What you need to do is:
a) Apply the patch.
b) In a text editor, edit the 4 exported Views files and remove the duplicated dependencies lines shown in #10 (and any similar duplicated dependencies lines).
c) Make a new patch and an interdiff file.

Thanks!

gauravkhambhala’s picture

The above patch does not apply successfully due to recent commits on this issue https://www.drupal.org/node/2309715
(Archive view & Recent content view). Will have to create new patch with latest code. And than do further changes for dependencies mentioned above.

jhodgdon’s picture

Sounds like a plan! Are you still planning to do this?

gauravkhambhala’s picture

Yes. I am on it. In addition I have observed that while I export view(archive view) from export configuration screen, it still exports "provider: block" instead of "provider: view". I wonder if this is a views export issue or i did something wrong. Following snippet from exported configuration of archive view.

block_1:
    id: block_1
    display_title: Block
    display_plugin: block
    position: 1
    provider: block
jhodgdon’s picture

I think we should report this on the other issue that supposedly fixed this:
#2309715: Several views still say they depend on block module but not anymore
so doing that now...

gauravkhambhala’s picture

Updated original patch with latest code. We do not need to have related issue Several views still say they depend on block module but not anymore (2309715) I did fresh installation with the updated code, #15 is no longer valid. I have removed it. This patch still has duplicate dependency views. I am creating new patch to remove this and than create interdiff.

Status: Needs review » Needs work

The last submitted patch, 17: 2323899_default_node_views_filtering_13.patch, failed testing.

jhodgdon’s picture

It looks like the Archive view lost its Page display in your patch.

gauravkhambhala’s picture

Status: Needs work » Needs review
FileSize
11.04 KB

You are right. Updated patch.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thank you! This patch looks good.

Gábor Hojtsy’s picture

Issue tags: +sprint
jhodgdon’s picture

And vice versa. Adding note to other issue too.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

#2037979: "Current user's language" views filter label is named very misleading just changed the name of ***CURRENT_LANGUAGE*** and friends, so this will need a small re-roll.

omers’s picture

Hi friends, i was practicing my drupal core ladder and try to give my two cents in a real issue, here is this patch with the small re-roll, i hope it works .

greetings

omers’s picture

Status: Needs work » Needs review
Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
8.97 KB

No interdiff was provided, so I diffed the two patches against each other. Looks like the only changes are indeed the special language codes.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: 2323899_default_node_views_filtering_25.patch, failed testing.

jhodgdon’s picture

The problem is that the patch doesn't apply...

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
11.27 KB

Direct reroll.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 577eab2 and pushed to 8.0.x. Thanks!

  • alexpott committed 577eab2 on 8.0.x
    Issue #2323899 by gauravkhambhala, Gábor Hojtsy, omers | jhodgdon:...
Gábor Hojtsy’s picture

Issue tags: -sprint

Thanks a lot!

omers’s picture

YEEEEIIIII!!!! my first mention in drupal core THANK YOU GUYS :)

webchick’s picture

Congrats, omers!! :)

omers’s picture

Thanks webchick !!!!, and let's go for more :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.