Problem/Motivation

The singular and plural string parameters on Drupal.formatPlural() calls should be literal strings, plural containing a @count placeholder. At Drupal.formatPlural( $table.find('tr:visible') in js/block.admin.es6.js. Read more at http://drupal.org/node/323109

The string there is

            Drupal.formatPlural(
              $table.find('tr:visible').length - 1,
              '1 block is available in the modified list.',
              '@count blocks are available in the modified list.',
            ),

which is completely valid.

Steps to reproduce

Extract strings from core block module.

Proposed resolution

preg_match_all('~[^\w]Drupal\s*\.\s*(t|formatPlural)\s*\([^)]+\)~s', $code, $faulty_matches, PREG_SET_ORDER);

I guess we need to tokenize (AST?) this instead of using a regexp. Or at least parse the argument separators "," and not only the parenthesis "()"

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Comments

penyaskito created an issue. See original summary.

gábor hojtsy’s picture

That may be valid, but we've not been supporting it. While it is possible to parse this, it does require a much more complex parsing solution that may be more error prone unless heavily automated-tested.

gábor hojtsy’s picture

Status: Active » Closed (duplicate)

Doing an issue triage on potx now. This is actually a duplicate of #3630552: JavaScript strings potx does not find: trailing commas, null arguments, template literals, which is fixed in 3.x.

The cause was not the parentheses of the count argument, $table.find('tr:visible').length - 1: 2.x currently extracts this call when there is no comma after the plural string. The cause was that comma at the. Since #3630552: JavaScript strings potx does not find: trailing commas, null arguments, template literals, 3.x accepts a comma after the plural string of Drupal.formatPlural() and after the string of Drupal.t(). 3.x extracts the strings of this call from the current core/modules/block/js/block.admin.js without errors: "1 block is available in the modified list." and "@count blocks are available in the modified list.".

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.