t() calls should be avoided in classes

Created on 13 March 2024, about 1 year ago
Updated 1 June 2024, 11 months ago

Drupal classes should not use t() to translate strings, but use dependency injection, for example via StringTranslationTrait.

📌 Task
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

🇮🇳India chaitanyadessai Goa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @chaitanyadessai
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India chaitanyadessai Goa

    Please review patch.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Assigned to apaderno
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Test classes should not use t(), since a test site always uses English as language. There is no need to translate messages, except in the case the class is testing translations.

    Since this issue is about t() calls, changes done to serialize() calls are off-topic.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    When a string is using t()-placeholders, but the string does not need to be translated, the FormattableMarkup class should be used.

    I created an issue fork, since issue forks should now be used instead of patches.

  • Status changed to Closed: duplicate 11 months ago
  • 🇧🇪Belgium nils.destoop

    Closing this as duplicate.

Production build 0.71.5 2024