Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Commons group module (commons_groups.module, lines 297-301) uses this code for a count of group conrtibutors text on commons all groups page (path like this: www.sitename.com/groups):
$contributors_count = $view->total_rows;
$output .= l(t('@contributors_count @contributors', array(
'@contributors_count' => $contributors_count,
'@contributors' => format_plural($contributors_count, 'contributor', 'contributors'),
)), 'node/' . $group->nid . '/contributors');
But it does not allow to translate a count of contributors text correctly (see this) - it does not need to use t() function, as i understood.
This changed code does work correctly:
$output .= l(format_plural($contributors_count, '1 contributor', '@count contributors'),
'node/' . $group->nid . '/contributors');
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#2 | remove-unnecessary-t-call-2210387-2.patch | 916 bytes | Devin Carlson |
commons_groups.jpeg | 32.96 KB | fun.boojum |
Comments
Comment #1
fun.boojum CreditAttribution: fun.boojum commentedComment #2
Devin Carlson CreditAttribution: Devin Carlson commentedGood catch!
As you mentioned,
format_plural()
handles translation itself so passing its output tot()
will cause problems.The attached patch removes the call to
t()
as is done in the OP.Comment #3
Devin Carlson CreditAttribution: Devin Carlson commentedTested #2 with an existing Commons installation and confirmed that the group contributor counts could be translated and continued to function properly with translation disabled.
Committed #2 to Commons 7.x-3.x.
http://drupalcode.org/project/commons.git/commit/a6d2038