Consider right-to-left languages when concatenating two translatable strings

Created on 21 August 2025, 8 days ago

For example, AccountSettingsForm::buildForm() uses the following code.

  $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:display-name], [user:account-name] [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');
  $form['email_admin_created'] = [
    '#type' => 'details',
    '#title' => $this->t('Welcome (new user created by administrator)'),
    '#open' => $config->get('register') == UserInterface::REGISTER_ADMINISTRATORS_ONLY,
    '#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
    '#group' => 'email',
  ];

In a right-to-left language, they would first read the translation for Available variables are: [site:name], [site:url], [user:display-name], [user:account-name] [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url]., and then the translation for Edit the welcome email messages sent to new member accounts created by an administrator.

With the following code, translators would be able to translate the two sentences in the right order.

  $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:display-name], [user:account-name] [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');
  $form['email_admin_created'] = [
    '#type' => 'details',
    '#title' => $this->t('Welcome (new user created by administrator)'),
    '#open' => $config->get('register') == UserInterface::REGISTER_ADMINISTRATORS_ONLY,
    '#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator. @email_token_help', ['@email_token_help' => $email_token_help]),
    '#group' => 'email',
  ];
📌 Task
Status

Active

Version

11.0 🔥

Component

user interface text

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024