[META] Discussion on translate form API fields by default

Created on 3 February 2015, over 10 years ago
Updated 30 April 2025, about 1 month ago

Hi,

Motivation:
The purpose of this discussion is to discuss whether displayed data of form elements (#title, #description) created using form API should be translated by default.

Description:
In short, why not convert this :

$form['foo'] = array(
  '#type' => 'foo',
  '#title' => $this->t('FooBar'),
  '#description' => $this->t('Description for the FooBar element.')
);

to

$form['foo'] = array(
  '#type' => 'foo',
  '#title' => 'FooBar',
  '#description' => 'Description for the FooBar element.'
);

Because #title and #descripion are made to be displayed on screen they have to be translatable. Why requiring developper to explicitely remind to translate it when it could be translated automatically for him ?

Impact:
- DX: As a developper, you don't have to remind this $this->t('') addition to those fields. Plus, second code looks cleaner for not having boilerplate repeated code.
- UX: As a user, you won't have to open an issue and wait simply because the module's dev have forgotten on field to be translatable. This would reduce the number of issue plus the time waiting for next module release until this is included as a fix.

Additionnal information:
I do understand that this is such a basic consideration that a debate probably already have happened. I could not find it on issue list, but this is not an intention to open a troll debate ! I a newbie at core contribution, please excuse me if it not the proper way to do so.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

forms system

Created by

πŸ‡«πŸ‡·France Dom.

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024