Problem/Motivation

layout-builder.js has formatPlural from Drupal with destructuring, so the block filter announcement uses no Drupal. to translate it:

const { ajax, behaviors, debounce, announce, formatPlural } = Drupal;

announce(
  formatPlural(
    $categories.find('.js-layout-builder-block-link:visible').length,
    '1 block is available in the modified list.',
    '@count blocks are available in the modified list.',
  ),
);

LocaleJs::parseJsFile() parses JS files, matching only Drupal.t() and Drupal.formatPlural() calls. Only strings found this way have a javascript location, so only these strings are exported into into the JavaScript translations of a site.

The same string is only in the JavaScript translations accidentally as the same sites usually load block.admin.js on the same pages and it has the same strings properly marked with Drupal.formatPlural().

Proposed resolution

layout-builder.js should call Drupal.formatPlural() directly, like the other JavaScript files of core, without formatPlural in the destructuring.

A rule against Drupal.t() and Drupal.formatPlural() from destructuring, in the JavaScript coding standards or as an ESLint rule, could be a follow-up.

Remaining tasks

Review.

User interface changes

None in English. In other languages, the announcement of the block filter is translatable on all sites.

API changes

None.

Data model changes

None.

Release notes snippet

None.

LLM disclosure

LLM was used to find, diagnose, explain and fix this issue. With human review.

Issue fork drupal-3631658

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

gábor hojtsy created an issue. See original summary.

gábor hojtsy’s picture

Title: The plural string of the block filter of Layout Builder is not found by JS string extraction » Plural strings for the block filter in Layout Builder are not found by JS string extraction

Simplify title :)

gábor hojtsy’s picture

Issue summary: View changes