Problem/Motivation
In #3095740-30: Convert menu_link_content, menu_ui module hook_help() to topic(s), @catch rightfully pointed out that we should be consistent in our help topics for the menu* system/module, with the term "menu link" and not call them "menu items".
However, the menu UI is not completely consistent.
As a note, the API docs in menu_ui.module nearly consistently call things "menu items", but this issue is not asking for that to change.
Here are the places where "item" is used instead of "link" under core/modules/menu_ui (excluding tests, which will most likely also need updates if they fail when the UI is updated):
./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php: public $messageWeight = 'You can only change the menu item weight for the <em>published</em> version of this content.';
./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php: public $messageParent = 'You can only change the parent menu item for the <em>published</em> version of this content.';
./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php: public $messageRemove = 'You can only remove the menu item in the <em>published</em> version of this content.';
./menu_ui.module: $form['menu']['link']['menu_parent']['#title'] = t('Parent item');
./menu_ui.module: '#title' => t('Default parent item'),
./menu_ui.module: '#description' => t('Choose the menu item to be the default parent for a new link in the content authoring form.'),
./menu_ui.module: $form_state->setErrorByName('menu_parent', t('The selected menu item is not under one of the selected menus.'));
And here is the one place under core/modules/menu_link_content that say "item" -- especially interesting, it uses both "link" and "item" in the same UI string?!?:
/src/Plugin/migrate/source/MenuLink.php: 'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
There are also a few pages in other modules (see comment #12).
Proposed resolution
Fix the UI text so that it consistently refers to menu links and not menu items, throughout Drupal core.
Remaining tasks
Make a patch, and get the tests to pass.
User interface changes
Consistent terminology for menu links.
Before patch:
After patch:
API changes
No.
Data model changes
No.
Release notes snippet
Not needed.
Comment | File | Size | Author |
---|---|---|---|
#19 | 3158562-19.patch | 27.21 KB | dww |
#18 | interdiff.txt | 14.98 KB | jhodgdon |
Comments
Comment #2
jhodgdonHere's a patch. I found a few places in System module as well, and changed them too, including the name of the permission for administering menus and menu links.
I expect the tests to pass, as I didn't try to find the tests that might refer to UI text having the phrase "menu item" in it.
Comment #4
jhodgdonAs expected, there were a few tests that checked for UI text that needed adjustment.
Comment #5
jhodgdonIf someone wants to make before/after screenshots of various pages in the menu UI, showing it saying both "link" and "item" before the patch, and just "link" after the patch, it could be helpful. Thanks!
Comment #6
pameeela CreditAttribution: pameeela commented@jhodgdon, added screenshots to IS. With the patch there is still one instance of 'menu item' in the 'Expand all menu items' setting for menu blocks:
Also I was unable to trigger the error
'The selected menu item is not under one of the selected menus.'
Anyone know a good way to do this? Or can we just verify via the patch? I tried creating a menu link in a node and then updating the content type settings to change the available menus, but the node edit form correctly updated in every case.Comment #7
pameeela CreditAttribution: pameeela commentedComment #8
pameeela CreditAttribution: pameeela commentedUpdated patch and some more screenshots.
Comment #9
pameeela CreditAttribution: pameeela commentedInterdiff for good measure :)
Comment #10
jhodgdonYour change looks good to me, and thanks for making all of those screenshots too, and finding that one place I missed! Now we need to find someone else to review the patch (both of us worked on it, so it would be best to have a different reviewer). And yes, I think the test is sufficient for verifying the error message.
Comment #11
Kristen PolI'm going to review now. Tagging for Bug Smash!
Comment #12
Kristen PolThanks for the update. The issue summary says we are supposed to focus on menu_ui yet I do see some code outside of that changed:
So... I checked for any remaining "menu item" and "parent item" that were not in 1) tests, 2) comments, or 3) backend code like schemaDefinition.
If we are to change *any* UI-facing code, then I see a few more things that appear to be shown to the user:
"menu item":
"...provides a default <em>Forums</em> menu item..."
"...provides a corresponding menu item..."
"...top-level administration menu items and links..."
$options['menu']['setting'] = $this->t('Parent menu item');
"parent item":
"...The path of a parent item..."
If these shouldn't be included, let me know and I'll just focus on the changes in the patch.
Comment #13
jhodgdonThanks! Yes, I think we should fix it everywhere. Updating the issue summary. Thanks for the more thorough check!
Comment #14
jhodgdon@pameeela, do you want to make the next patch? :)
Comment #15
dwwThanks for working on this! I love efforts to make Drupal more consistent and self-documenting. A menu "link" makes much more sense to mere mortals than an "item".
Patch looks really good (so far). Nothing to complain about that's already here.
However, this line from the summary concerns me:
IMHO, if the scope of this issue is 'Consistently refer to "menu links" as that, not "menu items"' I'm not sure why we should restrict it to the UI. It's a pet peeve to have the docs diverge from what they're documenting. Why not fix all of this at once?
So NW for either an expanded patch/scope here, or a follow-up to fix everything we're leaving out:
Before:
After:
A brief example of those 205 hits:
core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php: * The menu item's LI element is given one of the following classes:
IMHO that's just weird: a class called "MenuLinkTreeInterface" that's talking about a "menu item"... 😉
Thanks/sorry,
-Derek
p.s. I also noticed we've got some hits for "menuitem", too:
p.p.s. Ooof, x-post. Yeah, +1 to #12 - #14. ;)
Comment #16
jhodgdonYeah, let's make a separate issue for the API docs. It's most likely even worse than grepping 'menu item', as sometimes it might say "Something something menu has an item" or might have "menu" at the end of the line and "item" at the start of the next. And don't forget "parent item".
With this in mind... I went to localize.drupal.org, downloaded a PO file for 9.0.2, and searched for UI strings containing "item" or "Item", found a few more, and then figured out where they are. Usually, "item" is referring to an aggregator feed item, a content item, or some kind of generic word. But there are a few more referring to menu items, or to shortcut items (which are also links) and toolbar items (which I think are also links?)... So, I think we also need to fix (paths are relative to /core):
I'm not entirely sure about the toolbar ones.... we may need to think about that a bit....
Comment #17
dwwOkay, sounds reasonable. Follow-up opened as a child issue:
#3159213: Consistently refer to "menu links" as that, not "menu items", in code comments and docs
Needs follow-up😉Still NW for #12 and #16.
Thanks,
-Derek
Comment #18
jhodgdonIt seems that Toolbar should not be talking about links, except in the case of menus that are added to the toolbar, because toolbar "items" are actually "trays" with "toggles". See https://api.drupal.org/api/drupal/core%21modules%21toolbar%21toolbar.api... for more info.
Anyway, here's a patch that fixes the rest of the things in #12 and #16, at least I think so.
Comment #19
dww"Patch failed to apply". It's just minor fuzz due to #3155258: Use American English spelling of "gray"
Here's a trivial re-roll. Interdiff is empty, it's only s/grey/gray/ in a context line that's different, so here's a raw diff of the 2 patch files, instead.
Comment #20
jhodgdonThanks for that! I think I had the previous patch already applied, and didn't do the stash/pull/stash apply to make sure the repo was updated. Silly me!
Comment #21
simeI picked up a few more (looks like a lot more but here are a few) and I could make a new patch. Are these in scope?
In
system/templates/admin-block-content.html.twig
In
seven/templates/admin-block-content.html.twig
In
MenuLinkTreeInterface.php
Comment #22
dww@sime: Thanks, but all of those are comments, and therefore in scope for #3159213: Consistently refer to "menu links" as that, not "menu items", in code comments and docs, not here.
Cheers,
-Derek
Comment #23
simeLooks good. I've applied the patch. I've visually eye-balled each change in the patch. I grepped code for " item" then went through each reference to menu and confirmed there are no more end user facing references to "menu item".
Comment #24
simeComment #26
catchLooks good to me - reviewing the patch you can see us switching between item and link in the same sentence, let alone across the module.
Committed dcec533 and pushed to 9.1.x. Thanks!