Problem/Motivation

On Drupal 11.4.8 with Admin Toolbar 3.6.3, the Views-derived dropdown labels remain English in Spanish and Brazilian Portuguese. Content-type and media-type children translate correctly on the same pages.

Views-derived examples are the view labels listed under Structure > Views: Content, Files, People, Media library and Content blocks.

Admin Toolbar Tools derived these links with 'title' => $view->label(), a plain string captured when the menu links are derived, so the label of the language active at that moment was kept and the language overrides of the view labels were ignored.

Steps to reproduce

  1. Enable English, Spanish and Brazilian Portuguese, Admin Toolbar and Admin Toolbar Tools, with Views UI and Configuration Translation.
  2. Translate the label of a view (for example the Content view) in the language configuration overrides.
  3. Open the administrative pages in each interface language and expand the Structure > Views dropdown.
  4. Rebuild the caches and visit the languages in one order (English, then Spanish), then repeat after another rebuild in the reverse order.

Expected: each view link follows the interface language. Observed: the view labels stay in the language of the first rebuild.

Proposed resolution

Use the MenuLinkEntity menu link class for the Views links (as already done for the content types, media types, menus and roles), so the label is read from the view entity at render time, in the interface language.

Merge request !221 does this and adds tests:

  • AdminToolbarToolsViewsTranslationTest: the Views links follow the interface language in both cache orders, with a translated view label.
  • AdminToolbarToolsModuleLinksTranslationTest (with a small test module): the static menu links defined by other modules follow the interface language in both cache orders (see below).

Scope of this issue

The original report also mentioned module-derived labels, such as Security Review. From the investigation:

  • Security Review defines static YAML menu links, with the titles "Security review" (under Reports) and "Security Review" (under Configuration > System). Admin Toolbar does not create, derive or alter these links.
  • The titles of static links are translated by core from the interface translation catalog, which only matches an exact source string. A translation for "Security review" does not apply to "Security Review".
  • A test with two such links, differing only by their case, confirms that the translated link follows the interface language in both cache orders and that the other one stays English.

Therefore, module-derived labels are not covered by this issue, unless a link generated by Admin Toolbar Tools itself can be shown to stay in the wrong language. See the related issues below for the other topics.

Remaining tasks

  • Review and merge the merge request !221.
  • Reporter: confirm whether the module-derived labels are translated after adding the exact source strings (including capitalization) to the interface translations, or report a link generated by Admin Toolbar Tools that still remains English.

User interface changes

The links of the views in the Views dropdown follow the interface language.

API changes

None.

Data model changes

None. The menu links need to be rebuilt (cache rebuild) so the Views links use the new menu link class.

Command icon 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

jmcerda created an issue. See original summary.

wkr1shna made their first commit to this issue’s fork.

wkr1shna’s picture

Assigned: Unassigned » wkr1shna

dydave made their first commit to this issue’s fork.

dydave’s picture

Version: 3.6.3 » 3.x-dev
Assigned: wkr1shna » Unassigned

Super good catch Jeremy (@jmcerda)! Once again, thanks a lot! 🙏

Nice work Krishna (@wkr1shna)! The MR looks good! 🤩

I'll fix the pipeline issues quickly and give it a review so it could hopefully get merged very soon. 👌

dydave’s picture

Status: Active » Needs review

Thanks a lot everyone for your great help on this issue, once again! 🙏

OK, I fixed the phpstan and phpunit issues with an extra commit:
https://git.drupalcode.org/project/admin_toolbar/-/merge_requests/221/di...

and all the jobs and tests are back to passing 🟢, therefore moving issue to Needs review for now, as an attempt to get more reviews and testing feedback.

I have challenged the changes in the MR with an AI agent and got a rather positive report: The code is solid and accurately fixes the problem initially reported for the Views extra menu links.

Overall, Jeremy (@jmcerda), the changes in MR !221 should fix cases related with Views.

However, could you please help us clarify a bit what you meant with the following part?

Module-derived examples include Security Review. Available Spanish configuration targets included Bloques de contenido and Archivos, and the interface catalog contained Revisión de seguridad.

Expected: each link follows the interface language. Observed: these children stay English in both cache orders, while translated content/media-type children remain correct. The behavior also occurs with language-prefixed administrative paths, so it is not limited to an unprefixed admin-language preference.

Are you talking about the links in the admin_toolbar_search?
Which module-derived links are you talking about?
Could you please give us more examples?
 

At this point, I would recommend focusing on fixing the case for the Views menu link items, review/test the merge request, merge it, then create a follow-up issue to fix the rest of the cases.👍

Any additional information that could help us get a better understanding of the "module" related part of the requirements, would be very helpful.

Feel free to let us know if you have any questions or concerns on any of the code changes in the merge request or this comment in general, we would surely be glad to help.
Thanks again very much for your interest for the Admin Toolbar module! 🙏

(Great work Krishna @wkr1shna! Thanks a lot!)

dydave’s picture

Adding here a piece of the AI prompt for reference:

Related problem in search suggestions (not Views)

The labels in the search suggestions (SearchLinks.php) do follow the language. The cache is keyed by interface language, and the English and Spanish suggestions were correct. After editing only a Spanish translation, the tray updated correctly, but the Spanish search suggestion kept the old text (ES-n2 instead of ES2-n2). An English label edit updated correctly.

The cause is that the suggestions are cached with only config:core.extension and the list tags (for example config:node_type_list, config:menu_list). Saving a language override does not invalidate those. It only affects bundles beyond max_bundle_number, which the search gets from the server, and it lasts until the next invalidation. A likely fix is to add each bundle's and menu's own cache tags ($bundle->getCacheTags(), $menu->getCacheTags()) around lines 155 and 260 of SearchLinks.php. I have not implemented or tested that fix.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

StatusFileSize
new248 KB
new223.53 KB
new240.36 KB

✅ Tested and works — added a French label override ("Contenu FR-TEST") to the Content view and confirmed the Structure > Views dropdown showed "Content" on /fr/admin/structure/views; then checked out MR !221 as-is (not rebased on 3.x), rebuilt caches and reloaded: the dropdown now shows "Contenu FR-TEST" on /fr and "Content" on /admin/structure/views. The Views extra links follow the interface language; module-derived labels were not tested, per the maintainer's suggestion to handle them in a follow-up.

  • dydave committed 3af69441 on 3.x authored by wkr1shna
    Issue #3629740 by wkr1shna, dydave, csakiistvan, jmcerda: Fixed the...
dydave’s picture

Assigned: csakiistvan » Unassigned
Issue summary: View changes
Status: Needs review » Fixed

Merged, thanks a lot @jmcerda for the report, @wkr1shna for the fix, and @csakiistvan for the testing! 🙏

The Views links (Structure > Views) now follow the interface language in any cache order, since they use the MenuLinkEntity menu link class, like the content types and media types. The change has a test with a translated view label, in both cache orders.

About the module-derived labels mentioned in the issue summary (Security Review): I could not find any code in Admin Toolbar that creates or changes these links. The Security Review module defines static menu links with the titles "Security review" and "Security Review" (different capitalization), and core translates them from the interface translation catalog, only on an exact match of the source string.

I added a test with a small test module showing the static links of a module follow the interface language in both cache orders when the exact string is translated, while a link whose capitalization differs stays English.

@jmcerda: could you please check that the translation exists for the exact source string of each link (including the capital letters)? If a link generated by Admin Toolbar Tools still stays in the wrong language, please open a new issue with the steps, so we can look at it, and link it here.

I updated the title and summary of this issue to the Views links, which are fixed here. The other part found during the investigation, the search suggestions not refreshed after a translation-only edit, is moved to a new issue: #3635997: Admin Toolbar Search suggestions are not refreshed after editing only a translation

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.