Problem/Motivation

While doing #2073075, it was discovered that some classes are using global function t() - while including StringTranslationTrait, which has its own t() method.
We found it in field_ui's EntityDisplayModeListBuilder, FieldStorageConfigListBuilder - but these are fixed now in the related issue.

There definitely are more *ListBuilder classes in other modules (and possibly other classes using StringTranslationTrait) that should be changed. We didn't check how many yet.

Proposed resolution

The older t() can be replaced by $this->t().

Remaining tasks

  • find out how many changes there are to make
  • decide if this is novice or not
  • Change the code

User interface changes

No

API changes

No

Comments

roderik’s picture

FYI:
I spotted this in #2073075 which is just replacing t() with $this->t() now so I guess it should be done in the classes mentioned in the summary, too (and not in tests)...

...but tbh I don't know the best scope of this issue. (Per subsystem? Should we search for e.g. all classes using EntityHandlerBase in Drupal core, and do a patch for them in one go? Or is this cleanup part of another issue already - I couldn't find any.)

So anyone who has an opinion on that - please say it.

roderik’s picture

Title: Modernize field-ui/src directory » Phase out global t() in EntityListBuilder classes in field_ui module

(Rephrasing to current scope checked in the issue summary)

roderik’s picture

Issue tags: +Novice, +drupaldevdays

tagging

YesCT’s picture

Issue summary: View changes
Issue tags: -Novice

re-scoped based on a change in #2073075: Don't call the t() function in OO code in the field_ui module

removing novice until we know how giant this might end up being.

roderik’s picture

Title: Phase out global t() in EntityListBuilder classes in field_ui module » Phase out global t() in classes using StringTranslationTrait
Issue summary: View changes
xjm’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: vanilla-bear » Unassigned
Status: Needs work » Postponed

Thanks @vanilla-bear and @roderik for finding and filing this!

As a normal task, this especially needs to be checked against the Allowed changes during the Drupal 8 beta. Following through the chart there:

  1. This issue is not a feature request.
  2. This issue changes more than CSS, strings, markup, documentation, automated tests, or Migrate, so it is not unfrozen.
  3. This issue is not critical.
  4. The main goal of the issue is not usability, accessibility, performance, a bugfix, a backport, or removing code deprecated for 8.0.0. Note that t() is not marked deprecated.
  5. The issue is not major.
  6. The issue does not reduce fragility (which needs a maintainer's signoff).

So, we should postpone this change to 8.1.x. It's okay to make it in 8.1.x, because there will be no BC break.

However, I noticed that the docs for t() do not even mention the availability of StringTranslationTrait. So maybe we could file a separate issue to add documentation suggesting the use of StringTranslationTrait rather than t() in classes? That would be okay before 8.0.0 as it's just an improvement to documentation.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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.

quietone’s picture

Status: Postponed » Closed (duplicate)

Looks like the work this is to do is being done in #3113904: [META] Replace t() calls inside of classes . I think this can be closed as a duplicate.