Problem/Motivation

I'd like to export a list of all translation strings with `drush locale:export en | msguniq -`.

However, `msquniq` fails with a fatal error due to duplication of the empty string msgid:

$ ./bin/drush locale:export en | msguniq
: warning: Charset missing in header.
                  Message conversion to user's charset will not work.
:4632: duplicate message definition...
:4: ...this is the location of the first definition
msguniq: found 1 fatal error
$ ./bin/drush locale:export en | head -6             
# Global translation of ...........
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2021-07-08 10:28+0000\n"
testing@xpc:~/src$ 

and the lines 4632-4633

$ ./bin/drush locale:export en | head -4633 | tail -2
msgid ""
msgstr ""

Steps to reproduce

Not sure HOW the empty message string got in, so no steps to reproduce available.

This issue is identical to the report in https://www.drupal.org/project/drupal/issues/1940436 - so apparently there's a general pattern, spanning generations that this problem "returns".

So it's most likely something trivial like "import doesn't check whether msgid is empty :-p

Proposed resolution

- Never export the empty string at the API level
- Change the data model or API to raise a violation when trying to store the equivalent of an empty string for source.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3222777

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

spiffl created an issue. See original summary.

spiffl’s picture

Issue summary: View changes
spiffl’s picture

Note: While I have used drush to export the locale, the same also applies to translation files exported via the UI at /admin/config/regional/translate/export:

$ msguniq en.po 
en.po: warning: Charset missing in header.
                Message conversion to user's charset will not work.
en.po:4632: duplicate message definition...
en.po:4: ...this is the location of the first definition
msguniq: found 1 fatal error

gettext package version used

gettext (GNU gettext-runtime) 0.21

spiffl’s picture

Version: 8.9.x-dev » 9.2.x-dev
spiffl’s picture

Status: Active » Needs review
StatusFileSize
new774 bytes

See attached patch from the issue fork, which also applies to 8.9.16.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

This will need a test case to show the issue.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.