Problem/Motivation
If the site has an admin language preference option set in negotiation, users can set their admin language preference. However, even if that is set, only admin pages are affected. The admin toolbar is not. The admin toolbar displayed on non-admin pages will use the language of that page, not the admin language.
Proposed resolution
Negotiate an admin language for the toolbar and use that to render the menu.
Remaining tasks
Update release notes snippet and change record.
User interface changes
The admin toolbar will be in an admin-appropriate language.
API changes
See release notes snippet.
Release notes snippet
- \Drupal\user\ToolbarLinkBuilder requires now a new parameter of type \Drupal\Core\Extension\ModuleHandlerInterface. Custom modules extending ToolbarLinkBuilder should adjust the code accordingly.
- New cache context: \Drupal\Core\Cache\Context\AccountAdminLanguageCacheContext
- New method setCurrentLanguage introduced to LanguageManager
- New service: \Drupal\language\AdminLanguageRender
Issue fork drupal-2313309
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
plach+1 for an admin language type, it could be used for other UI elements such as local tasks/actions and contextual links.
Comment #2
gábor hojtsyThis is way more trickier than I thought. Some problems:
Here is a sketch of a patch for an admin language assuming if an admin is viewing the toolbar, they always want the toolbar in their admin preferred language. Otherwise it uses the page's language, but looks more elaborate just so we can pass around the langcode needed. Also modified the toolbar path to be an admin path, so the menu generated there will be in the admin language as well.
These are all theories, I could not really prove that this works yet :D I have some hard to debug issues here.
Comment #3
gábor hojtsy@plach: yeah an admin language type would be a possible solution for this, but what language an admin page resolves to depends on specific config vs. the path used to access it, so not sure how a new type would work?
Comment #4
gábor hojtsyComment #6
gábor hojtsyDuh, fix invoke pattern.
Comment #7
gábor hojtsyAll right, here is a test that proves the problem. It will still fail once with the "fix" included because the fix is not complete. The top level items of the toolbar are rendered in the admin language but the menu is not. There is no way to ask for the menu to be rendered in a specific language that I know of, it just uses the language of the page :/ That would be the last potion to solve this.
Comment #10
gábor hojtsyYeah results exactly as expected. If we can figure out how to render the top menu items in the admin language, then it would resolved.
Comment #11
plachI still think a new language type could be the solution here: if we define a non-configurable admin language type having as hardcoded negotiation settings something like
admin language > UI language, then every UI element can decide whether it is and administrative item and default to the current Admin language. It shouldn't be hard to add a flag to a menu definition to mark it as "administrative".Comment #12
gábor hojtsyI would not hardcode that because if you have admin negotiation enabled, then admin users have the setting show up. If you don't want that, then you would not have a way to disable it. If we want this by default, then maybe we want an admin type that is configurable but is not configured by default (like content language).
Comment #13
plachIIRC the user admin page checks whether the admin language detection methods is enabled for the UI language type, if not it should be very easy to add a check. Anyway, do you think it would really make sense to configure an Admin language type? IMHO its meaning is pretty well-defined, not sure what alternative choices the user would be supposed to make.
Comment #14
gábor hojtsyWell, if we are to have an admin language type, then what it is useful for to have the admin negotiation enabled in the UI type? You would have it enabled in the admin type, right? :)
Comment #15
gábor hojtsyComment #16
plachYes, but the current UI is pretty confusing if one has just to enable/disable admin language support. Wouldn't a single custom checkbox work better?
Comment #17
gábor hojtsyThat sounds pretty special that your admin language would work if the admin language TYPE is enabled to be customized, which would have the admin language negotiator enabled all the time?! Not sure tying that to the customization checking on the admin type is a good idea?!
Comment #18
plachI am not sure I follow, I'll try to recap my proposal to see whether I can explain it better:
admin language>UI languageEdit: The admin language detection method is bound to the admin language type and cannot be used elsewhere.
Comment #19
gábor hojtsyYeah that custom checkbox bothers me then... I thought we could make this work with the negotiation setting or the type setting or somesuch... I agree the combination of needing to enable the type and then the negotiation within is painful :/
Comment #20
plachWe could also leave it always enabled and use a NULL default for users, so that Admin language is not active until explicitly configured. We could also add a permission to control access to the widget on user pages.
Comment #21
gábor hojtsyYeah we already use a null default for users since #2313157: Optimize admin language detection and make it optional (admittedly one day ago :D).
Comment #22
gábor hojtsyNot being worked on.
Comment #25
reekris commentedI am currently experiencing this issue in a Drupal 8 project using 8.0.5. I opened a related issue before finding this one #2688741: Administration pages language ignored in toolbar when viewing regular pages. It could probably be closed in favor of this one?
From reading through this thread it seems that #18 sound very similar to the
Administration pages languagethat is currently in core, but it would be much more usable than the current solution. I don't see any good use case for wanting to have admin pages including the toolbar in a special language but not when viewing non-admin pages. In my opinion it would be much better with an "admin language" setting, that affected admin pages, admin toolbar, contextual items, drupal messages. etc everything that is seen as an admin string, no matter what page you are on.Would it be possible to progress further on this issue and maybe get a fix in 8.0.x or is it postponed?
Comment #28
lba_emanuel commentedI will work on this patch re-roll for few hours.
Comment #29
lba_emanuel commentedAs 2313309-toolbar-language-7.patch didn't apply anymore.
I had to rewrite all in every files 8.2.x . So didn't created an interdiff.
So my patch covers the same previous patch. I didn't had time to take into account comment since #7
Still need work.
Comment #30
olafski(Gábor Hojtsy, https://www.drupal.org/node/2189267#comment-11754752)
@Gábor Hojtsy - Unfortunately I can't help coding but I'm very interested in this issue which is quite important in my opinion.
@lba_emanuel - Are you planning to continue your work on the issue? Does it make sense to test the last patch, or should I wait?
Comment #31
Mojtaba Reyhani commentedI added a RTL Language translation File (Like: Persian, Farsi) to my drupal 8 site and What I simply want is to All "Administration Pages language" (or backend Language) in english only and all admin menu Always in left side and frontend pages of the site(Site Language) in another language (Like: persian, Farsi)
I do below setting:
1- I enabled the Language module, and set-up one additional language. Install was done in En (english), and I added Fa (Persian) language.

Language Module Configuration
2- I configure the administration language separate to the content language by below setting:
Interface text language Configuration

3-Admin -> Edit Profile -> Edit(Tab)

Configuration of Administration Language
This work properly for all administration page and those are English and in left side (LTR) except the
"home page"and"user/1/"andadmin/structure/block/demo/'Theme Name'of the site that the administration menu is in Persian Language and in right side (RTL) yet.Administration Pages

Home Page

Comment #32
jimmyX commentedI followed Mojtaba Reyhani's steps, and I don't know if I have different expectations (he says this is working perfectly), but for me it does not work as expected. If I set the administration page language to English under Admin -> Edit Profile -> Edit(Tab), then I cannot edit any content in other languages; it only lets me edit pages in English. If I don't set that, then I can edit content in other languages, but then the admin toolbars are also shown in that other language. I can't tell if I'm doing something wrong, or if this is an ongoing issue.
Comment #34
mogio_hh commentedIn Drupal 8.24 it is NOT working.
Admin language is set to "en" - still the tool bar is shown in "japanese" in my case. Can't read anything. So the existence of the toolbar is useless in frontend pages of foreign languages.
Anybody encounters the same issue?
Comment #35
svdhout commentedI've done a workaround for this problem by translating the local tasks and discovered links in a hook
I do not really like the workaround, but it seems to work for now.
Comment #36
jbfelix commentedHello
How do you implement your workaround ?
In a module ?
Comment #37
nvakenI think that workaround code is flawed, comments imply that this implements certain hooks while it actually doesn't apply to those hooks.
Comment #38
nvakenWhat's the status of this issue? It seems that some assume that this already works as designed in D8? Though some of the others (include) seem to still get the admin menu in non-admin-language on the frontend of the site.
Comment #40
casey commentedA (very hacky) fix to get this working for a client.
This also needs patches from:
What we really need, I think, is a generic way to switch languages during handling of a single request.
Comment #41
jbd44 commentedMaybe this can help someone: https://drupal.stackexchange.com/questions/246793/multilingual-content-a....
Comment #43
andreyjan commentedI have the following case:
Multi-site installation.
One of the sites is multilingual and the the other one is not. The site which is not multilingual is crashing with the error:
Call to undefined method Drupal\Core\Language\LanguageManager::setCurrentLanguage() in Drupal\toolbar\Element\Toolbar::switchToUserAdminLanguage()
Refactored #40 patch to check if the site is multilingual and also added some code improvements..
Not sure if it still can be committed to core, but it definitely needs to be covered by tests.
Comment #44
guncha25 commentedPatch didn't really work with all menu. I have fixed user links and contextual links also.
Comment #45
matthiasm11 commentedI can confirm the patch from #44 works in combination with patch #78 from #2189267: When content language detection is different from interface language detection, the detected language is not applied to the rendered content.
Comment #47
clairedesbois@gmail.comIs that bug still relevant? I applied the patch from #2189267: When content language detection is different from interface language detection, the detected language is not applied to the rendered content. The admin toolbar works correctly and appears in english when I'm on the french version. My only problem now is the active tasks bar where menu items from administrative actions (Edit, Translate, etc.) appear in french instead of english.
I'm on Drupal 8.6.1.
Comment #48
nitebreedNote that if you use the Admin Toolbar module (https://www.drupal.org/project/admin_toolbar), this patch doesn't have any effect!
Comment #49
upchuk commentedI also confirm #47.
RE #48, I believe that is outside the scope. Getting the core Toolbar working in the admin language is what needs to happen no?
Comment #50
johnwebdev commentedI think this should be done on a more generic level and not specifically towards Admin toolbar, as mentioned previously, i.e. if using something like Layout Builder I might want to display the interface in the administrative language.
Comment #51
upchuk commentedQuick note that #2189267: When content language detection is different from interface language detection, the detected language is not applied to the rendered content was merged and this is probably no longer needed. For me #47 stands true.
Comment #52
lpeabody commentedI'm operating on Drupal 8.6.7, and with this patch applied. I can confirm two things:
1) With this patch applied, admin_toolbar DOES render in the language specified in the user's administrative pages language settings.
2) Without this patch applied, admin_toolbar DOES NOT render against the user's administrative pages language setting.
The same is true about the toolbar on it's own (i.e. admin_toolbar uninstalled, toolbar enabled).
So, IMHO this patch is still needed. Given it works exactly as I expect it to, I'll switch this to RTBC.
Comment #53
plachComment #56
sun-fire commentedAll works fine for me with patch #44 (core version 8.6.12), but I had this issue without using of this patch. So, this patch is still needed.
Comment #57
tunicI've created a similar issue but for local task labels (see #3054641: Local tasks should honor selected admin interface language (if set)).
If current issue doesn't address translation of Contextual Links I guess a new issue should be created. It seems this is addressed in #44, but is not mentioned in issue's title nor in the summary, we shouldn't forget it.
I've tested patch #44 and seems to work for the Admin Toolbar, but I've not clear results about contextual filters (I didn't work for one test, but given I've a heavily patched Drupal site probably was a secondary effect). Although tests still fail, ti works ok on a Drupal installation.
Comment #58
dionsj@tunic I've been running the patch from #44 on several different sites we are working on and a local test site, and on all of them it seems that the contextual filters (quick edit etc.) have mixed translations for some reason, in the attached image it is of a site with 2 language (Installed with English, added Danish later and made it default language). I've checked that the translations aren't missing or attached to the wrong langcode, but all looked good.
So it does not look like the contextual filters are fixed, at least not during my testing, but it does fix the admin toolbar as expected.
If you know how to fix the contextual links, please by all means make an issue for it and post a patch, I'll gladly help test it out.
Comment #61
nikitas commentedHi, for Drupal 8.8.5 i can confirm that #44 works as expected but i can not apply the #78 or any other (most recept) patch (2189267-100.patch or 2189267-98.patch).
Comment #62
pachabhaiya commentedPatch #44 works for me too on Drupal 8.8.6.
Comment #63
hardik_patel_12 commentedWorking on it.
Comment #64
hardik_patel_12 commentedSolving test cases.
Comment #66
istankevych commentedDrupal 8.8.6
I have multisite configuration.
First one use translations, but for second Language module is disabled.
With this patch (#44) I got next error (on site without Language module):
Comment #67
aimevpI wanted to test the patch in #64 but immediately got the following fatal error:
Error: Using $this when not in object context in Drupal\language\ConfigurableLanguageManager::switchToUserAdminLanguage() (line 269 of core/modules/language/src/ConfigurableLanguageManager.php).After comparing the code from the patch in #44 I noticed on lines 269 and 294 the variable "$languageManager" was replaced with "$this". Reverting it back to "$languageManager" (see attached patch) fixed the error but I'm not experienced enough to be sure if this is correct or if there's a reason why the original author of the patch used "$this".
I hope I've helped a little bit and didn't made it worse.
FYI: this patch was tested and works on a D8.9.3 install
Comment #68
jeroentCreated a reroll for Drupal 9 + added
trustedCallbacksmethod toConfigurableLanguageManager.Comment #71
lubwn commentedPatch from #68 is working fine for me on 8.9.7, but contexual filters are still being translated and also tabs are still being translated as well. But admin menu is working nice now.
Comment #72
tunic#71, local tasks (tabs) are being handled on this issue: #3054641: Local tasks should honor selected admin interface language (if set).
Also, it's interesting that the patch is working for you but tests for pacth from #68 reports 89 errors.
Comment #73
tunicErrors from #68 don't seem random errors because I've scheduled a re-test and fails the same way.
Comment #74
anmolgoyal74 commentedHandled CS messages.
Comment #76
anmolgoyal74 commentedComment #78
nikitagupta commentedFixed the test case.
Comment #80
jhedstromI think all the tests failing were due to this. I don't think adding the
languagemodule to those tests is the proper fix, since the error being thrown in those tests will happen on any site that doesn't have the language module enabled.Rather, I think only conditionally adding these pre/post render callbacks if the language module is enabled makes more sense. I'm going to take a look at that now.
Comment #81
nwom commented#78 no longer applied against 9.2.x:
Here is a re-roll. Nothing else was changed, so no need for an interdiff.
Comment #82
jeroentWell let's see if approach in #80 works.
Comment #83
jeroentComment #85
jeroentComment #87
jeroentComment #88
jeroentComment #89
jeroentComment #90
jeroentComment #91
jeroentAdded test coverage for contextual links, toolbar and links provided by user_toolbar().
Comment #92
jeroentComment #93
jeroentComment #94
jeroentComment #96
jeroentComment #97
parisekpatch needs reroll
Comment #98
tunicComment #100
duaelfrThere you go!
Comment #101
ahmad abbad commented+1
Comment #102
duaelfrFYI, #100 patch applies on 9.2.x and 9.2.0-beta2 too.
Comment #103
anybodyConfirming RTBC for #100. Are we ready to set this RTBC?
Comment #104
chrisss commented#100 works well, but there is one small issue still - for arabic (or any rtl language) the layout is still appearing in right to left format. it's a bit weird to have this when the text is in english. I was thinking of just overriding this in my theme with css but it might be a good idea to include this in the patch if it's going to be committed soon.
also maybe unrelated, but is there a similar patch or workaround to get the theme local task links/tabs to appear always in english as well?
thanks!
Comment #105
duaelfr@chrisss Good point! We could add a
dirattribute on the toolbar wrapper.You'll find the patch you need for local tasks here: #3054641: Local tasks should honor selected admin interface language (if set)
Comment #106
chrisss commented@DuaelFr I tried that actually but the issue is that the css currently gets the
dirattribute from the parent element, so it's still overridden. Might need some css hacking.Also thanks for the link!
Comment #107
philyPatch #100 seems to be working well using Drupal 9.2.1 with French (admin + content) and English (content) languages.
Thanks
Comment #108
jeroentNeeds work for #104.
Comment #109
jeroentComment #110
jeroentComment #111
jeroentI was trying to fix #104 but it's not as simple as adding a
dirattribute on the toolbar wrapper since styling is also added to the body element. e.g. in toolbar.module.css:Comment #112
parisekI have conflict with LoginDestination which decorates ToolbarLinkBuilder class
https://git.drupalcode.org/search?search=LoginDestinationToolbarLinkBuil...
We probably cannot inject moduleHandler as it breaks compatibility with other modules
ArgumentCountError: Too few arguments to function Drupal\user\ToolbarLinkBuilder::__construct(), 1 passed in /Users/pari/Sites/drupal8/cimex/web/modules/contrib/login_destination/src/LoginDestinationToolbarLinkBuilder.php on line 41 and exactly 2 expected in Drupal\user\ToolbarLinkBuilder->__construct() (line 40 of core/modules/user/src/ToolbarLinkBuilder.php).
Comment #113
daften commented@parisek
login_destination implements a decorator pattern, but in the wrong way. It is completely up to contrib to make sure the implementations are correct.
Side information: decorators should not extend the class they're decorating. They should implement the correct interface, implement all methods and use $this->inner->method calls for each method they're not decorating. This mistake is made often though, but it shouldn't block improvements from going in core imo.
Comment #114
seyfettinkahveci commentedPatch on #100 didn't work for core 9.2.5. The reason is due to the following 2 files
1. When I examined the patch, I saw that the line in the file "core/misc/cspell/dictionary.txt" was added to the core. I deleted these lines from patch.
2. I saw that the file "core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php" has changed. I manually adapted the patch according to the current file.
Comment #115
emek commentedIn one of my environments I can't apply the patch in #114, I get the following message: "error: patch fragment without header at line 580: @@ -55,9 +55,8 @@ class ToolbarMenuTranslationTest extends BrowserTestBase {"
Since I could apply it in one of my other environments I was able to recreate it and now it works well.
The block for the file core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php was moved in the new patch.
Comment #116
vsujeetkumar commentedFixed the "custom command fail" issue.
Added word "entitynodedelete" in the cspell/dictionary.txt file. As per my understanding we can also ignore this word because it is on the test file however the related word 'entitynodeedit' also available in the dictionary file, on the basis of that I have added this word also, Please have a look and advise.
Comment #118
emek commentedThe patch in #116 didn't apply for me in 9.3.0
I recreated it, there was some functions that had some changes in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php and there was some changes in core/misc/cspell/dictionary.txt which caused the patch to not apply. I recreated the patch so it applies.
Unfortunately I couldn't create an interdiff for the changes.
Comment #121
gaurav_manerkar commentedHi,
Which patch will work for 9.3?
Comment #122
unstatu commentedI have improved a little bit the path #116:
- The sentences that come from configuration entities are also translated managed (for example the content types names)
- Checked the same permissions that are used in order to decide to show or hide the Administration pages languages option in the user profile (web/core/modules/user/src/AccountForm.php:255)
- Removed the LanguageInterface::TYPE_INTERFACE since it's the default one
Comment #126
akalam commentedI created a new MR based on #122 againt the branch 9.3.x https://git.drupalcode.org/project/drupal/-/merge_requests/1713
Comment #127
timohuismanI've created a patch file from #126. We prefer a patch file because a MR url is moving target.
Comment #129
donapis commentedThe patch in #127 is working for me.
Comment #131
cgoffin commentedI think there is still a problem with cache. When you change the language on the user profile page the toolbar isn't in the right language. I guess this is because the toolbar is cached based on the interface language and not on the user's admin language. I added a CacheContext for the preferred admin language and added it to the toolbar element.
Comment #132
alexpottI think we should decouple the contextual link changes from the toolbar changes.I'm 100% sure that the toolbar should be in the user's admin language. Contextual links are a bit trickier because there are probably use-cases where the admin language might bit be the correct choice - that said writing that down I'm struggling to actually come up with a use-case so let's fix up the issue title to reflect what this patch is fixing.Comment #133
alexpottHere's a patch that hopefully passes tests and works for the toolbar and contextual links. Will write up a comment with some additional thoughts later.
Comment #135
jeroentThis should fix the failing tests.
Comment #136
yonailoHello,
I am experiencing issues when trying to apply this patch for keeping the english language in the form "media_library_add_form_upload".
I have a custom module with a form_alter, which does "$form = AdminLanguageRender::applyTo($form);"
But it seems that the AJAX callback is broken after this. I have been able to trace the issue and it seems that it is related with "Drupal\media_library\Form\AddFormBase::buildActions()". The "save select" action uses $value => $this->t('Save'), which is translated to "Enregistrer". After this, #pre_render seems to show the action button as "Save", but when clicking on save the triggeringElement() is not correctly detected.
I have changed the code of "buildActions" in order to use $value = 'Save', just for testing, and in this case everything works well.
Maybe this fonctionality is not thought to be used by $forms ? Is there any solution that would allow it to be used in forms, specially in forms with AJAX requests ?
Comment #138
emek commentedI could not apply the patch in #135 on Drupal 9.4
Here is a new patch that applies.
Comment #139
simohell commented[edit: my comment was addressed before I posted, hadn't refreshed the page]
Comment #140
emek commented@simohell can you unhide my patch if it works for you, or should I upload it again?
Comment #141
ovanes commentedHello
I have just tried to apply the patch from 135 comment but it happened that did not applied.
I am using Drupal core 9.4.x. It seems the reason way is that from that file dictionary.txt is missing that line entitynodeedit. It used be there in Drupal core 9.3.x but it seems it is not longer there in Drupal core 9.4.x
I have just added that to the patch and it applied for me.
P.S. if that line needs to be removed then we just need to remove it and the patch will apply again.
Comment #142
borisson_I've found a couple of nitpicks
80 cols
should this be olivero now?
only one of these has a short description, all of them should
Needs @return documentation
Comment #143
akashkumar07 commentedThis patch covers all the suggestions mentioned in #142.
Comment #144
proteo commentedI've been using the patch from #143 in a site with 5 languages for a couple of days and it works like a charm (Drupal 9.4.4).
Thank you!
Comment #145
jeroen dost commentedI used this patch (2313309-143.patch) on Drupal 9.4.4. The patch is successfully deployed, but it breaks the site:
The website encountered an unexpected error. Please try again later.
InvalidArgumentException: Class "language.admin_language_render" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core\lib\Drupal\Core\DependencyInjection\ClassResolver.php).
Drupal\Core\Controller\ControllerResolver->createController('language.admin_language_render:switchToUserAdminLanguage') (Line: 69)
Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition('language.admin_language_render:switchToUserAdminLanguage') (Line: 760)
Drupal\Core\Render\Renderer->doCallback('#pre_render', 'language.admin_language_render:switchToUserAdminLanguage', Array) (Line: 363)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 85)
__TwigTemplate_64381f4af3c78cf09ccf72dcbfcb0abed14b23cd5876352e631da3cc7c98b69d->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/front/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 422)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 162)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 163)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 46)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
(Removing only the patch restores the site, so it "must" be the patch.)
PHP version: 7.4.16
Comment #146
guaneagler commentedAs the patch conflicts with another one(https://www.drupal.org/project/drupal/issues/3101231), so I combine these two patches together.
Comment #148
guaneagler commentedAdd the combined patch and add the enable option for the new feature.
Comment #149
borisson_#146 and #148 are not needed here, if you need the combined patch it would probably be better to just put it in your own project. I also don't see the relation between both issues, they might touch the same code but they feel very different in scope and purpose.
It seems like the error in #145 is enough to actually move it back to NW.
@Jeroen Dost does a cache rebuild after applying the patch make the error go away? It sounds like the service definition can't be found but there is a definition in service.yml, if that fixes it we just need an update hook, otherwise we're going to have to figure out what else could be causing this.
Comment #150
markdc#143 is working well for me. (D9.4.5 / PHP 8.0.22)
Comment #152
borisson_Was hoping to get a response from @Jeroen Dost about their missing class error but I think that was just a cache problem somewhere.
Reuploaded the patch from #143 and setting it to needs review. Would like to see if this still passes tests.
Comment #153
ahmad abbad commentedPatch #152 is working with me
Comment #154
ahmad abbad commentedComment #155
ameymudras commentedTested on Drupal 10.1.x and php 8.1
- The issue summary is clear
- The patch applies cleanly
- Tested contextual links for multiple languages and works as expected
- #135 and #154 already includes screenshots so avoiding for repeatation
- No code issues noticed
Moving to RTBC
Comment #156
larowlanI'm pretty sure the API addition here (the new method on the configurable language manager) makes this only eligible for a minor release, so I think we should add return type hints and use constructor property promotion here.
Let's add some return type hints here
Are these still needed, I don't see them anywhere else in the patch
nit >80 here on an array
Whilst I know this is testing what we want, is there any way we can do it without using a WebDriver based test, which are typically slow and flaky?
Because there's an API change here (the new method on ConfigurableLanguageManager), this is likely 10.1 only.
So let's use constructor property promotion here.
Let's add some type hints and return types here
Let's add a return type hint here for : array
Shouldn't we be adding this to the interface too?
Also, let's add a string type hint for $type and either make this method fluent (return $this) or add a void return typ
This isn't necessarily so - see #1044090: Enable toolbar for authenticated users also, so that non-admin users can use shortcuts as well
we can use constructor property promotion here.
I was going to ask if we need to do a deprecation dance here, but there's no sub-classes in contrib according to https://git.drupalcode.org/search?search=ToolbarLinkBuilder&group_id=2 so we can probably just go with a change notice
Tagging for release not and change record
Comment #157
borisson_Looks like more work is also needed to support layout builder sections/blocks (in
\Drupal\layout_builder\Element\LayoutBuilder::buildAddSectionLink/\Drupal\layout_builder\Element\LayoutBuilder::buildAdministrativeSection, I think).Is there a way to add a test that allows us to test if other frontend UI items are also translated?
Comment #158
leo liao commentedAdd the combined patch and add the enable option for the new feature.
Comment #159
michaelsoetaertI've rerolled the patch in #158 so that it applies on the latest versions (
10.1.x,10.0.4&9.5.4).Comment #160
n.ghunaim commentedI implement a small fix to patch #152, I assigned a NULL value to moduleHandler on the _construct function
public function __construct(AccountProxyInterface $account, ModuleHandlerInterface $moduleHandler = NULL) {in ToolbarLinkBuilder.php file as I get this error when running the patch.
Comment #161
joao.ramos.costa commentedRerolled #152 for 9.5.4 .
Comment #162
joao.ramos.costa commentedFixes #161 patch.
Comment #163
wylbur commentedThe patch in comment #162 applied cleanly to 9.5.5
Comment #164
leo liao commentedAdd the combined patch and add the enable option for the new feature. for 9.5.5
Comment #165
andrew.wang commentedComment #167
snehauskoim commentedPatch #162 has applied but contextual links are totally disappeared in some cases in layout builder
Comment #168
kpaxman commentedI see #149 says that #146 and #148 are not needed, and #164 seems to be an extension of those. Should anyone outside of the people posting those patches be using them? I'm not sure what the point is of an enable option, given that is just honoring existing config.
Comment #170
dieterholvoet commentedI started a new branch based off 11.x with the patch from #152 and the feedback from #156. Only the refactoring of the WebDriver based test hasn't been done yet. Let's stop posting patches now to avoid confusion, especially patching combining multiple issues. These don't belong here.
Regarding the typehint related feedback in #156: I'm not sure we should add typehints if the parent class hasn't decided on a typehint. For example,
CacheContextInterface::getLabelcurrently hasstringdocumented as return type, but we also have to account for instances ofTranslatableMarkupthere. How exactly that should be done hasn't been decided yet, so we shouldn't either in the child class.Regarding #160, there's a separate issue for that problem in the login_destination queue: #3261748: LoginDestinationToolbarLinkBuilder implements the decorator pattern in a wrong way.
Comment #172
timohuismanThis patch represents the current state of MR created in #170. We prefer patch files as long as the merge request urls are considered dangerous, see https://github.com/cweagans/composer-patches/issues/347.
Comment #173
timohuismanThis time with a valid patch file extension...
Comment #174
joao.ramos.costa commentedHI @timohuisman,
thank you for the heads up!
Comment #175
recrit commentedI'm not sure what #173 was, but it was not created with https://git.drupalcode.org/project/drupal/-/merge_requests/4604.diff.
Attached is the new 11.x MR 4604 at commit 7975cb1f.
Comment #176
tvalimaa commentedUpdated:
#175 gave me error but I got it working. This patch didn't solve my toolbar problem
Comment #177
johnshortessThe patch in #173 was working for us in 10.1.x. But it no longer applies in 10.2.0, nor does the patch from MR 4604. I'll take a look to see what's changed, but it may be several days until I have time.
Comment #178
linhnm commentedRerolled the patch #173 for Drupal 10.2.0
Comment #179
linhnm commentedFixes #178 patch
Comment #180
mathieu.h commented#179 works, thx!
Comment #181
andrew.wang commentedI didn't review the code but just wanna report that #179 works well for me on a big site running Drupal 10.2.1!
Comment #182
carlos romero commented#179
Works on drupal 11.0-dev
new branch with the commit of patch 179:
https://git.drupalcode.org/issue/drupal-2313309/-/tree/2313309-179-11.x
and MR:
https://git.drupalcode.org/project/drupal/-/merge_requests/6351
thanks!
Comment #184
manikandank03 commentedPatch #179 works fine in Drupal 10.2.2 with PHP 8.2.
Comment #185
zeip commentedThe patch in #179 fixed this for us. The merge requests !4604 and !6351 both include the patch file, which shouldn't be included in the MR's but at least !6351 looks otherwise ok.
Comment #186
smulvih2#179 works for me in Drupal 10.2.2 using PHP8.1.
Comment #187
matthiasm11 commented+1 for #179. Drupal 10.2.6 using PHP 8.2.
Comment #188
carlos romero commentedComment #189
andrew.wang commentedComment #193
sokru commentedI hide all other branches than MR 4604. I rebased it and addressed the parts of feedback from #156 that where missing, except for
- Typehints not done per #170.
- #156.5: Is still open question.
- #156.8: Instead of adding typehint, made https://www.drupal.org/node/3349470, that seems still need a work with tests (AutowireTest)
This still needs work:
- Fix issues on MR 4604
- Needs change record
- Needs release note
Comment #194
sokru commentedFixed the tests and created a draft for change record and release notes.
Comment #195
smustgrave commented@sokru thanks for hiding the old MRs, also good to hide all patches since those aren't needed anymore and the bot could pick them up.
Left some comments on the MR.
Comment #196
sokru commentedAll the feedback has been addressed.
Comment #197
carlos romero commentedComment #198
smustgrave commentedFeedback does appear to be addressed
But CR https://www.drupal.org/node/3456217 is empty
Comment #205
sleitner commentedAdded details to CR https://www.drupal.org/node/3456217
Comment #206
ronttizz commentedTbh I am not entirely sure do I understand the whole process and issue but I tested this with Umami. The site has english and spanish out of the box. These are my findings.
I selected spanish as my admin preferred language.
For the language change block on Umami site it seems that these are using spanish
But "Umami Home Banner" block these are not translated.
Tbh, I am not sure are these in the scope of this issue.
Otherwise it seems that all the top admin nav/toolbar is respecting the admin language and they are spanish even though I am browsing the site in english.
Comment #207
smustgrave commentedThanks @sleitner for updating the CR
@ronttizz your issue sounds like a block issue. Would recommend searching the issue queue to see if there is a similar ticket and leave a comment. Sometimes a simple comment of "saw this today on 10.3 while testing xyz" could bring people back to it. Joy of open source! haha
Feedback on the MR here appears to be address
Comment #208
nod_This looks good to me. Anyone tried it with navigation module? Make it a follow-up if it doesn't work we don't need to solve it here, This has always annoyed me so big +1 to this :)
Comment #209
irafah commentedAfter updating the site from version 10.3.1 to 10.3.2 and applying patch #179, the site went down - `The website encountered an unexpected error.`
The main error:
What is weird is that the class is indeed there and I can even access it by clicking ctrl+click over the class, which shows that it does find it
Has anyone faced anything like this with core 10.3.2?
Comment #210
frontmobeI applied the patch on a site that was already running Drupal 10.3.2 (php 8.2.13, Apache 2.4.54) and could not replicate the behaviour that was described in #209, the patch worked as expected on this install.
Specifically I did the following:
- put the patch link in the "patches" section of the root composer.json and ran composer install, the patch (in #179) applied cleanly.
- logged into the site as an administrator and opened a page in dutch, the admin had dutch set as the "Administration pages language" on his profile, the administration menu items in the toolbar showed in dutch, as expected.
- changed the "Administration pages language" in the admin profile to english and opened the same dutch page, the administration menu links now showed in english, as expected.
Based on this behaviour it seems that the patch functions correctly on this install running Drupal 10.3.2, I also checked the logs for anything unusual but all was working perfectly fine. Hope this helps!
Comment #211
irafah commentedI started the update over and this time it worked as expected. Might have been a local issue
Thanks for looking
Comment #212
alexpottI left some review comments on the MR that should be addressed.
Comment #213
sokru commentedResolved the threads created by @alexpott and created a follow-up issue for Navigation module #3472043: [PP-1] Navigation module should honor admin language on frontpage and node route.
Comment #214
smustgrave commentedGave it another lap but mostly small stuff.
Looking at the CR they may need a little work, especially https://www.drupal.org/node/3456217 should include the service being called in the example.
Comment #215
sokru commentedAddressed the latest feedback. However I didn't modify the change record, since I could not think up of any useful example and I did not find any other change record which would give an examples of new services. Given the age of this issue I think the CR can be updated later if someone comes up with any useful examples.
Comment #216
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #217
needs-review-queue-bot commentedFalse positive
Comment #218
carma03 commentedConfirming patch #179 works on D10.2.7 and PHP8.2.
Comment #219
szato commentedI am using MR diff to patch D10.3.6, php 8.3. Works.
Comment #220
frontmobeI performed the same routine as I used in #210 to check the patch in #179, this time using Drupal 10.3.6 and PHP 8.3.13. The patch works as expected.
Comment #221
sagarmohite0031 commentedHello,
Getting error while applying Mr
attaching screenshot
Comment #222
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #223
yevko commentedMR doesn't apply on 11.1.x
Comment #224
sokru commentedComment #225
kekkisThanks @kallevu for the update on the MR! I tried working on that on the global contrib weekend but failed miserably. It would be nice if this could move forward now that it seems to produce green results too.
Comment #226
gillesv commentedI can confirm what @yevko's saying: the MR does not apply on 11.1.x
This change is rejected on "modules/language/language.module", probably because the dev-version of 11 looks quite different there:
Comment #227
sokru commentedThe MR is not supposed to be applied to 11.1.x but on 11.x branch. If this gets accepted to 11.x then we can create a MR for 11.1.x.
Comment #228
smustgrave commentedResolved most threads but left just a few more.
Question what happens if admin_langcode is not included.
If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #230
robin.houtevelts commentedI've addressed the threads in the MR.
Consider the following setup:
ENNL- No preference -Currently:
Account::getPreferredAdminLangcode(fallback_to_default: TRUE)Account::getPreferredAdminLangcode(fallback_to_default: FALSE)This difference results in the toolbar and contextual links rendering in
NL, while theuser.admin_languagecache context falls back toEN. This inconsistency indeed needs to be addressed.AccountAdminLanguageCacheContextneeds to accurately reflect the user's actual setting. In this case- No preference -, so it should usefallback_to_default: FALSEinstead ofTRUE.(👆This still needs to happen.)
While testing, I noticed some contextual links were translated and others were not. The tests pass, but I'm not confident.
I'm including a recording.
Comment #231
weseze commentedAny chance of a patch against latest D11 stable release?
I could not get it working based on the MR diff/patch, tried to fix it manually but I was out of my depth there...
Comment #232
sleitner commentedRerolled
Comment #233
sleitner commentedRerolled and removed not matched ignoreErrors
Comment #234
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #235
sleitner commentedRerolled
Comment #236
hmdnawaz commentedpatch form MR for 11.2
Comment #237
smustgrave commentedThis is looking good but see we had to update a lot of tests across a number of modules. Makes me think this could be a BC, can add a test where admin_langcode is omitted to show it won't break,.
Comment #238
sleitner commentedAdded a test which tests the contextual toolbar with and without admin language set.
Added a theme cache context to fix the issue @robin.houtevelts mentioned in #230.
Comment #239
sleitner commentedBumped to 11.4
Comment #240
sleitner commentedRerolled again with performance test limbo. Please review.
Comment #242
almador commentedRecently updated Drupal 9.5.11 to 10.6.1
After applyin the patch #179 this WSOD error appears on many pages:
ArgumentCountError: Too few arguments to function Drupal\user\ToolbarLinkBuilder::__construct(), 1 passed in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 and exactly 2 expected in Drupal\user\ToolbarLinkBuilder->__construct() (line 27 of core/modules/user/src/ToolbarLinkBuilder.php).Comment #243
sleitner commentedRerolled again with performance test limbo. Please review.
Comment #244
dench011.3.1
Comment #245
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #247
sleitner commentedRerolled again. Please review.
Comment #250
sleitner commentedComment #255
idflood commentedSorry for the wrong merge request. Patch #244 still applies cleanly on D11 but I had another issue which made it fail. Now that it applied cleanly it works as expected.
Comment #257
recrit commentedThe patch in #244 is no longer applying to 11.3 due to the changes in the `core/profiles/demo_umami/tests`. For that reason, I have rolled a D11.3 patch that does not have the changes to `core/profiles/demo_umami/tests` so that it applies cleanly to D11.3.
I would have contributed to the MR, but the MR 6351 appears to have erroneous changes most likely due to some rebasing. It is showing a lot of unrelated changes.