Remove uses of t() in setLabel() and setDescription() calls

Created on 19 June 2020, over 4 years ago
Updated 21 December 2023, 9 months ago

Problem/Motivation

There is no need to use t() in tests, unless we're testing translations, however in core we do not follow this consistently, which does not set a good example for new contributions.

In 📌 [meta] Remove usage of t() in tests not testing translation Active we identified there are severals of calls to t() in calls to setLabel() and setDescription() and that removing all these in one go seems to be a suitable way of attacking this problem.

Proposed resolution

Identify and remove all calls to t() wrapped in calls to setLabel() and setDescription(), except those used by translation-related code (if any).

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Closed: won't fix

Version

11.0 🔥

Component
Other 

Last updated about 4 hours ago

Created by

🇮🇳India Hardik_Patel_12 India

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

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.

  • 🇳🇿New Zealand quietone

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

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India chaitanyadessai Goa

    Removed t() calls from setLabel() and setDescription().

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    @chaitanyadessai please include an interdiff with your patches

    Doing a search for ->setLabel(t(
    Showed more instances from test files I don't think are related to revisions

    Same for setDescription

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India adeshsharma Bhopal

    Removed t calls.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Seems all instances have been removed. So guess we weren't testing translation of either of those. Should we open a follow up to add testing?

  • Status changed to Needs work over 1 year ago
  • 🇬🇧United Kingdom longwave UK

    This still needs discussion as to whether we should actually do it, as per #14 through #18.

  • Status changed to Needs review 9 months ago
  • 🇬🇧United Kingdom longwave UK

    Thinking this through some more after working on the final t() removals in tests in 📌 Remove remaining unnecessary uses of t() in tests Active , I now think this is won't fix - we need test coverage of TranslatableMarkup passed through to various common APIs like render, form and field API and test coverage should provide good examples to use as well.

    Marking "needs review" for this comment, hiding all other patches.

  • 🇬🇧United Kingdom longwave UK

    Explaining a bit further:

    In real-world implementations of setLabel() and similar methods we use t(). By removing t() in tests we are not really testing the same way a real-world implementation would, if we only used raw strings in tests then how would be sure that the code actually works with translatable strings?

    Also, tests are sometimes used as examples of features and the code is copy-pasted and then edited and used for real. If we drop t() here we risk people copy-pasting and not following the best practice of adding translatable labels and descriptions.

    It's similar to when we have a test form. In most test form implementations we still wrap form element labels in t() because that's what a real world implementation of a form should do.

  • Status changed to Closed: won't fix 9 months ago
  • 🇺🇸United States smustgrave

    Explanation makes sense, anyone really disagrees please reopne.

Production build 0.71.5 2024