Part of #500866: [META] remove t() from assert message
Follow-up to #1803674: Remove t() from default test assertions in TestBase class
The WebTestBase class should not contain calls to t() for format_plural().
All t() calls should be replaced with String::format().
Plain text strings without token replacements can be output directly.
Calls to format_plural() are to be replaced with English plural rules, which means this:
- $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
+ $message = $emailCount == 1 ? '1 e-mail was sent during this test.' : $emailCount . ' e-mails were sent during this test.';
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-2195623-2.patch | 19.75 KB | olli |
Comments
Comment #1
jhodgdonPossibly this would be a good Novice project, for a motivated novice? Or non-novice. Either way. :)
Comment #2
olli commentedComment #3
jhodgdonThanks!
This patch was very carefully done. I checked it over carefully, and am reasonably certain it is removing t() from the right places, and leaving it in where I believe we still want it (such as translating the submit button text in code like this:
I also verified there are no format_plural() calls in WebTestBase, and that it caught everything.
I especially love the irony that there were all these documentation comments in WebTestBase:
followed just a few lines later by the default message being translated with t(). Um. :)
Great job on the patch!
Comment #4
sunThanks, this looks great.
Comment #5
catchCommitted/pushed to 8.x, thanks!