Use t() for #title and #description in tests and test modules

Created on 9 July 2020, over 4 years ago
Updated 30 January 2023, about 2 years ago
 function views_test_classy_subtheme_views_ui_display_tab_alter(&$build, ViewUI $view, $display_id) {
-  $build['details']['top']['display_title']['#description'] = 'This is text added to the display edit form';
+  $build['details']['top']['display_title']['#description'] = t('This is text added to the display edit form');
๐Ÿ“Œ Task
Status

Needs work

Version

10.1 โœจ

Component
Otherย  โ†’

Last updated 1 day ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia shaktik New Delhi

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot โ†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Tagging for coding standards and moving to the 'other' component where such issues live.

  • Status changed to Needs review almost 2 years ago
  • last update almost 2 years ago
    Patch Failed to Apply
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chaitanyadessai Goa

    Patch added.

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Issue summary is incomplete.

    And this feels like counter active of only using t() in tests when testing translation.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia atul4drupal

    Added patch for 11.x
    Interdiff is not generated as the patch at #49 is not applying to have the interdiff generated (interdiff: Error applying patch1 to reconstructed file)

    IS to be updated...

  • last update over 1 year ago
    30,392 pass
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    The reason for this change is not in any of the comments and the documentation https://www.drupal.org/docs/develop/automated-testing/phpunit-in-drupal/phpunit-browser-test-tutorial#t clearly states not to do this. Thanks to @AJV009 for pointing that out.

    What is the reason for doing this? How does it help developers?

  • Status changed to Needs work 8 months ago
  • The Needs Review Queue Bot โ†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request โ†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    What is the scope here? The patch here is for test modules but the issue title is for all tests.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Re #55 it definitely shouldn't be in actual test code (i.e inside PHPUnit tests) as that is unnecessary and will break phpstan typing as well, we've been trying to move away from using t() inside phpunit tests entirely.

    IMO this issue doesn't seem that necessary to begin with. The IS states it's for easier copy-paste but the vast majority of test code and modules are very specific and should not be copy-pasted into runtime code. In fact I'd almost go the opposite way and remove t() calls in tests if anything.

    We also need the changes in an MR.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @acbramley, thanks. Seems this needs more discussion.

    Let's hold off on an MR for more discussion.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    I brought this up in committer slack where catch, alexpott, gรกbor hojtsy, longwave and myself, We agreed that it is not good practice to copy/pasted test code to production. As @acbramley points out test code can be specific. It may not be a good example to use which poses a risk when a less experience developer copies it. So let's avoid that. There was also a suggestion that a better way to enforce the use of t() for these properties would be to do so in the Form API itself. That is, if we want to do it.

    I added on the doc page that Drupal core does use t(0 in browser tests that are testing translation.

    Thank you to everyone who worked on this, which led to clarifying the situation.

Production build 0.71.5 2024