drush locale check Deletes Specific .po Files and Replaces with General .po Files

Created on 20 June 2024, 5 months ago
Updated 3 July 2024, 5 months ago

Problem/Motivation

When running the drush locale:check command on our Drupal site, we have encountered a recurring issue where existing .po files are deleted and replaced with more general .po files if a specific .po file for a module or core version is not found. For example, we are currently running Drupal core version 10.2.7 and have a drupal-10.2.6-de.po file. When drush locale:check is executed, this file gets deleted and replaced with a drupal-10.x-de.po file.

Steps to reproduce (only until a new 10.2.7 .po file is available)

Steps to Reproduce
Use Drupal core version 10.2.7.
Place a specific .po file (e.g., drupal-10.2.6-de.po) in the translations directory.
Run the command drush locale:check.
Observe that the specific .po file is deleted and replaced by a more general drupal-10.x-de.po file.

Expected Behavior
The drush locale:check command should check for and update translations without deleting existing .po files that are specific to the current Drupal core version or modules.

Actual Behavior
The drush locale:check command deletes existing version-specific .po files if they are not matched and replaces them with more general .po files. This causes a loss of specific translations that were manually added.

Impact
This behavior is problematic as it leads to the loss of detailed and specific translations. It also introduces additional manual steps to ensure translations are correctly reapplied after running drush locale:check.

Possible Workarounds
Manually download and place the necessary .po files after running drush locale:check.
Use scripts to ensure the presence of specific .po files and prevent their deletion.

Suggested Solution
Enhance the drush locale:check functionality to preserve existing .po files and avoid replacing them with general files unless explicitly instructed. Alternatively, implement a more intelligent matching mechanism that respects version-specific files and only updates when a correct replacement is found.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
LocaleΒ  β†’

Last updated 3 days ago

Created by

πŸ‡©πŸ‡ͺGermany macdev_drupal Wiesbaden

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

Comments & Activities

  • Issue created by @macdev_drupal
  • Status changed to Postponed: needs info 5 months ago
  • locale:check entirely in Drush and this bug may not be fix-able in Drupal Core. I think you may have to report this to Drush.

  • Status changed to Active 5 months ago
  • πŸ‡©πŸ‡ͺGermany macdev_drupal Wiesbaden

    Drush hands over to the local module. So I think this should be addressed there.
    Just checked
    web/core/modules/locale/locale.fetch.inc
    web/core/modules/locale/locale.batch.inc
    the methods there are just triggered from drush locale:check and the business logic is in those methods.
    Maybe there could be a fall back, before deleting / renaming .po files locally.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies. Also, 10.2 is in security mode now.

  • πŸ‡©πŸ‡ͺGermany alxn

    I can confirm that drush locale:check deletes module translation files in the translations folder. Subsequently running drush locale:update then leads to the error [error] TypeError: fgets(): Argument #1 ($stream) must be of type resource, bool given in fgets() (line 248 of /var/www/html/docroot/core/lib/Drupal/Component/Gettext/PoStreamReader.php), apparently because a translation file could not be read.

    Drupal version : 10.2.7
    PHP version : 8.1.27
    Drush version : 12.5.3.0

Production build 0.71.5 2024