Some block categories are not translatable

Created on 4 June 2015, about 10 years ago
Updated 26 June 2025, 12 days ago

Problem/Motivation

Some blocks in the block layout library are grouped under the label "System", some under the translation of "System"

Steps to reproduce

  1. Install in another language than english
  2. Login as admin
  3. Go to the block layout page admin/structure/block

Alternative:

  1. Login as admin
  2. Enable multilanguage modules
  3. Add another language
  4. Interface-translate "System"
  5. Go to the block layout page admin/structure/block

Multiple instances of "System" are not translated while some are. See the screenshots below, where "System" was translated to "TEST" in German.

Noticed in #2019511: Explain why the language switcher would not show under some configurations β†’

Proposed resolution

Remaining tasks

User interface changes

Before


After


All system blocks are now in translatable categories.

API changes

No.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

block.module

Created by

πŸ‡ΊπŸ‡ΈUnited States yesct

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !12496BlockDefinitionsTest β†’ (Open) created by mstrelan
  • Pipeline finished with Failed
    12 days ago
    Total: 389s
    #531855
  • Pipeline finished with Success
    12 days ago
    Total: 996s
    #531860
  • Pipeline finished with Failed
    12 days ago
    Total: 135s
    #531874
  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Spun up an MR and started with the (slightly refactored) test from #27. Can see the test-only results at https://git.drupalcode.org/issue/drupal-2500607/-/jobs/5680572

    1) Drupal\Tests\block\Kernel\BlockDefinitionsTest::testBlockCategory
    Block plugins missing categories: views_exposed_filter_block, views_block, system_powered_by_block, system_messages_block, system_main_block, system_breadcrumb_block, system_branding_block, system_clear_cache_block, navigation_user, navigation_shortcuts, navigation_link, field_block, extra_field_block, help_block, announce_block, local_tasks_block, local_actions_block, page_title_block
    Failed asserting that an array is empty.
    

    I then applied all the same categories from the existing patches, but of course we have attributes instead of annotations now, so had to be done manually. There were some new plugins revealed by the failing test so I added categories for those as well.

    Then I added in the changes to CategorizingPluginManagerTrait and CategorizingPluginManagerTraitTest, but didn't quite follow @alexpott's comment in #33. Maybe it wasn't clear that this is a fallback, so we get the "provider" and try to translate that.

    Guessing the IS needs an update, maybe some new screenshots.

  • Pipeline finished with Success
    12 days ago
    Total: 837s
    #531884
  • The Needs Review Queue Bot β†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request β†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Ok thanks bot. Hiding patches, even though I think they are useful for confirming that the MR is on the right track.

  • πŸ‡ΊπŸ‡ΈUnited States xjm

    Amending attribution.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can we update the summary with a proposed solution.

    Also this brings up a question about attributes, if we are adding a new key how do we ensure contrib/custom modules update theirs too? WOuld have to be done in the attribute itself?

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Can we update the summary with a proposed solution.

    Done

    Also this brings up a question about attributes, if we are adding a new key how do we ensure contrib/custom modules update theirs too? WOuld have to be done in the attribute itself?

    The key already exists in the attribute, but it's optional. We're ensuring all core blocks have a category set. Contrib/custom will fallback to the module name, which we're now translating. Although I was under the impression we're only meant to translate string literals, so not sure if that part is suitable. We could always deprecate not passing a category, but that could be pretty annoying.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Did a search for #[Block and there appear to still be other instances

    Mainly test blocks, if those aren't needed can we least update the block.api

    If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    I don't think we need to do the test blocks. Category is still optional, we're just ensuring core blocks set the category. I've updated the example in block.api.php

    I'm still unsure about the fallback translation in CategorizingPluginManagerTrait. If we have that, why bother enforcing all the core blocks have a category?

  • Pipeline finished with Success
    about 20 hours ago
    Total: 661s
    #540509
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    idk if a good search but I looked for $definition['provider'] and didn't see any other spots that are doing translations.

Production build 0.71.5 2024