Locale translatables with non-javascript source are removed from Babel table (wrong JS alter logic)

Created on 11 July 2025, about 1 month ago

Problem/Motivation

The fix added in πŸ› Query condition 'bs.id IN ()' cannot be empty" after install Active now removes all the Locale translatable strings with non-javascript source from Babel table.

First query https://git.drupalcode.org/project/babel/-/blob/77b114370905382ae1ef68e2... 'Load all sources where the location is javascript'.

  $query = $db->select('locales_source', 'ls');
  $query->innerJoin('locales_location', 'll', 'ls.lid = ll.sid');
  $sources = $query
    ->fields('ls', ['lid', 'source', 'context'])
    ->condition('ll.type', 'javascript')
    ->execute()
    ->fetchAllAssoc('lid');

Second one https://git.drupalcode.org/project/babel/-/blob/77b114370905382ae1ef68e2... 'Load all 'locale' records from Babel source'.

  $ids = $db->select('babel_source', 'bs')
    ->fields('bs', ['id'])
    ->condition('bs.plugin', 'locale')
    ->execute()
    ->fetchCol();

The problem is, whenever translations are updated (you add or remove on or just install a module), majority of the Babel source records is removed because most of the locale strings aren't coming from JavaScript.

Steps to reproduce

  1. Install standard, enable Babel and Language
  2. Add a language, e.g. int Portuguese
  3. As anonymous, hit /user/login once, with Portuguese interface (visit /pt/user/login); just to be sure that "Log in" was translated once.
  4. Try to find the ID of the "Log in" string in the babel_source table.

Proposed resolution

I don't really understand when should strings being removed from this table, but the current logic is wrong for sure.

Remaining tasks

Identify the situation(s) when records must be removed from babel_source table after locale was rebuild.

User interface changes

Nothing.

API changes

Nothing.

Data model changes

Nothing.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary huzooka Hungary πŸ‡­πŸ‡ΊπŸ‡ͺπŸ‡Ί

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