Problem/Motivation

t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead.
Remove uses of t() in assertions has been done in the issue https://www.drupal.org/project/drupal/issues/3133726.
Remove all calls to t() wrapped in calls to drupalPostForm() will be done in the issue https://www.drupal.org/project/drupal/issues/3145005.

Steps to reproduce

Proposed resolution

Remaining tasks

Replace all remaning occurance of t() calls with $this->t() in classes.

User interface changes

API changes

Data model changes

Comments

siddhant.bhosale created an issue. See original summary.

siddhant.bhosale’s picture

Assigned: siddhant.bhosale » Unassigned
Status: Active » Needs review
StatusFileSize
new3.01 KB

Hi, I have uploaded the patch, Please review.

siddhant.bhosale’s picture

Issue summary: View changes
akshay kashyap’s picture

StatusFileSize
new18.53 KB
new22.48 KB

I have applied #2 patch its working fine but some files you missed the t() so i created a new patch for that

Status: Needs review » Needs work

The last submitted patch, 4: 3164942-3.patch, failed testing. View results

siddhant.bhosale’s picture

hi Akshay kashyap, Can you please check the issue in summary, we have a diffrenet issue for replacing t() in assertions.

abhibhatt’s picture

I have checked the patch #2(3164942-2.patch)in my machine and its working fine for me.

abhibhatt’s picture

Status: Needs work » Needs review

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

longwave’s picture

Status: Needs review » Closed (duplicate)

Thanks for working on this.

In general, issues should not be scoped by file or module; instead, they should be scoped by making the exact specific change across as much of core as possible. Reference: https://www.drupal.org/core/scope#files

In particular, t() calls should be replaced based on whether the translation service is already available in the class, and more specifically, based on which base class it extends. (So, for example, one issue for form builders, one for controllers, one for list builders, and then splitting that up further only if the resulting patch is too large to be manageable.) We also need to decide the approach before we proceed with child issues. See #3113904: [META] Replace t() calls inside of classes for more discussion. So, closing as a duplicate of the parent issue in #3113904: [META] Replace t() calls inside of classes .

Thanks!