Drupal.t() does not respect locale_custom_strings

Created on 28 August 2023, about 1 year ago
Updated 11 September 2023, about 1 year ago

Problem/Motivation

This is a D10 issue from 🐛 [D7] Drupal.t() does not respect locale_custom_strings Fixed .

It is possible to define locale_custom_strings_XX in settings.php to override specific string translations.

* String overrides:
*
* To override specific strings on your site with or without enabling the Locale
* module, add an entry to this list. This functionality allows you to change
* a small number of your site's default English language interface strings.

This is working for strings translated via t(), but if a string is being translated via Drupal.t() in javascript, the override is not respected and has no effect.

I think that Drupal.t() should also respect locale_custom_strings_XX.

Steps to reproduce

Easiest way to reproduce is:

1. enable second language (for example German)
2. specify some string overrides in settings.php, for example:

 $settings['locale_custom_strings_de'][''] = [
   'Label' => 'LabelCUSTOM',
   'Edit' => 'EditCUSTOM',
  'List additional actions' => 'Additional actions ACTIONS!',
 ];

3. Go to /de/admin/structure/types/manage/page/fields/add-field
4. You can see the "Label" and "Edit" strings are overriden correctly, but the "List additional actions" (in the dropbutton) is not, as this is coming from Drupal.t() (instead it has "Bearbeiten as a correct German translation). See the screenshot.

Proposed resolution

Drupal.t() should respect the string overrides.

Remaining tasks

Write test.
Fix the issue.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.1

Component
Language system 

Last updated about 23 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇸🇰Slovakia poker10

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

Comments & Activities

Production build 0.71.5 2024