Problem/Motivation
In #2484037: Make Views bulk operations entity translation aware @webchick reported (after setting up an English site and adding French too):
Config entity lists:
Content entity lists:
Proposed resolution
1. On config entity lists, keep the current admin language as-is. This is resolved by adding ['language' => NULL] to URL options when creating operations for config entities. Those will keep the language.
2. On content entity lists (which are views based), update the entity operations field to consider the language of the views row found, generate links using that language.
Remaining tasks
Discuss how to improve content operation languages to also enable to keep the interface language by linking to specific edit URLs.
User interface changes
1. Config entity lists should link all operations to pages in the same language as the page is viewed in.
2. Content entity lists should link operations to the language relevant for the row displayed at least (ideally keeping the interface language and linking to specific operation pages for the language).
API changes
EntityOperation field in views gets a new LanguageManager constructor argument.
Comment | File | Size | Author |
---|---|---|---|
#37 | bug.png | 148.3 KB | _renify_ |
#17 | 2504663-17.patch | 13.73 KB | Gábor Hojtsy |
#17 | interdiff.txt | 1.3 KB | Gábor Hojtsy |
#15 | interdiff.txt | 9.84 KB | Gábor Hojtsy |
#15 | 2504663-15.patch | 13.21 KB | Gábor Hojtsy |
Comments
Comment #1
Gábor HojtsyComment #2
Gábor HojtsyComment #3
tim.plunkettCan you confirm if this is also true for other dropbuttons like those on the content types page?
Comment #4
Wim LeersSounds like a missing cache context?
Comment #5
Gábor Hojtsy@tim.plunkett: yeah I had this earlier in the issue summary: This is true to menus, users, etc. so not unique to views or config entity listings either.. I verified with those pages. SO looks like independent of what is doing the listing.
Comment #6
Wim LeersThen it sounds like the operations links don't point to the right translation.
Debugging hints:
\Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton()
$element['#links']['edit']['url']->toUriString()
— it should point to a route beginning with thecontent_translation.translation_edit_
prefix, but it's probably pointing to the original entity edit/delete/… links.Comment #7
Gábor HojtsyWell, they don't need to be a content_translation route, the bug affects config entity listings just as well. I don't think the route needs to be different for the language to be different :) Eg. if I go to hu/admin/structure/menu, all the operations link out of /hu to / but the Add menu, breadcrumbs, etc. are correctly pointing to /hu links.
On /hu/admin/structure/menu the dropbutton Uri debug for the first menu is:
So looks like an explicit English is set in the route options.
Comment #8
Gábor HojtsyIt is also not a general dropbutton problem. Dropbuttons on hu/admin/config/regional/config-translation work very well, dropbuttons on hu/admin/config/regional/config-translation/view fall back on English again. Looks like it depends on whether its based on entity links.
As per Entity::urlInfo():
So entity links will have an explicit language set :/
Comment #9
Wim LeersGreat investigative work!
Comment #10
Gábor HojtsyNot sure at this point though how to fix this and its a major at least because we are supposed to let people edit a Chinese block on an English UI, but there is no way to get there from the English list if the block was Chinese...
Comment #11
Gábor HojtsyHere is an inverse example with installing in Hungarian and adding English as second language. This time with menus :)
Comment #12
Gábor HojtsyDifferent symptom of this same bug:
Comment #13
Wim LeersThis is definitely related to #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons. I wonder if that is in fact the cause?
Comment #14
Gábor HojtsyHere is a partial patch that at least matches expectations for a few of the config entity listings. Did not "fix" all config entity default operations, but eg. menus fully work as expected with this. The destination of the edit form submissions is still not good (it breaks out of interface language again), but this gives an idea of the extent of changes needed :/ Hopefully we can do it more elegantly...
Comment #15
Gábor HojtsyAdding the remaining config entity controller fixes.
And finally the views operations fix for loading the entity in the right language (similar to the BulkForm plugin). It looks like this is not invoked every time, but is cached indeed :/
Comment #16
Wim LeersOkay, I think/fear that means this is blocked on #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons.
Comment #17
Gábor HojtsyWell, not sure. It is cached for further page loads, but not within the page. All rows get invoked properly one by one. I forgot to add the query ensurace / langcode alias setting method (again same as BulkForm field), so now it starts to work much closer to what someone would expect.
Comment #18
Gábor HojtsyNow for content entities I think the question is whether we should swap to the specific content entity edit path and keep the UI language or break out of the UI language for the respective content translation language (the later is what the patch does now).
Comment #19
Gábor HojtsyComment #20
Gábor HojtsyComment #21
Gábor HojtsyComment #31
amateescu CreditAttribution: amateescu as a volunteer commentedThis looks like a duplicate of #2476563: Entity operations links tied to original entity language, ignore everything else.
Comment #32
Gábor Hojtsy@amateescu: looks like it, yeah, I'll merge my changes there :)
Comment #33
Gábor HojtsyIntgrated everything there in comment #39 and #40. Let's keep moving there then.
Comment #34
jhodgdonUmmmmm... Which issue is this a duplicate of? The reference in comment #32 is to this issue itself. And the only at that time open related issue is #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons, which is about cacheability, and has no mention of things here being merged in. Opening this back up until this is clarified.
Comment #35
Gábor Hojtsy@jhodgdon: the titles are similar, but the issue in #31 (not #32) is different.
Comment #36
jhodgdonTitles and issue node IDs are both similar, ha! Updating meta... thanks!
Comment #37
_renify_ CreditAttribution: _renify_ as a volunteer commentedStill has bug on User entity