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.
I want to remove t() from all the documented example code in BrowserTestBase.
This best describes why.
https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial
When to use t() in browser tests
Never! Nope, not in assertion messages, not for button labels, not for text you assert on the page. You always want to test the literal string on the page, you don't want to test the Drupal translation system.
------
It is too big a job to remove t('example') from our code ... it will go away slowly in years to come.
But we should stop documenting it in our examples now.
Comment | File | Size | Author |
---|---|---|---|
#10 | charm-2875148-9.patch | 3 KB | martin107 |
#9 | interdiff-2875148-9.txt | 2.49 KB | martin107 |
#9 | charm-2875148-9.txt | 3 KB | martin107 |
Comments
Comment #2
martin107 CreditAttribution: martin107 as a volunteer commentedMy fellow Bostonians, I humbly suggest the first step is for us to throw the tea in the harbour.
Comment #3
martin107 CreditAttribution: martin107 as a volunteer commentedComment #4
dawehnerMaybe we should explitely mention to not use the t() function, what do you think?
Comment #5
martin107 CreditAttribution: martin107 as a volunteer commentedI agree, added at the top of the class.
PS made issue summary more readable.
Comment #6
dawehnerThank you @martin107!
Comment #7
martin107 CreditAttribution: martin107 as a volunteer commentedComment #8
alexpottI think we should say something like
Tests extending this base class should only translate text when testing translation functionality. For example, avoid wrapping test text with t() or TranslatableMarkup().
Since t() is deprecated and on the way out.
These comments can re-flowed
Comment #9
martin107 CreditAttribution: martin107 as a volunteer commented8.1) Sure, adopting a more informative tone, is better.
8.2) Reflowed.
Comment #10
martin107 CreditAttribution: martin107 as a volunteer commentedI knew making quark jokes would get me into trouble.
Comment #12
borisson_This patch still applies, it's a great idea to improve this documentation. It changed the changes requested in #8.
Comment #14
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!
Comment #16
Mile23Anyone want to improve Examples on this? #2924223: Remove t() from tests