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
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3222777-ensure-empty-msgid-is-never-emitted.patch | 774 bytes | spiffl |
Issue fork drupal-3222777
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
Comment #2
spiffl commentedComment #3
spiffl commentedComment #4
spiffl commentedNote: 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 errorgettext package version used
gettext (GNU gettext-runtime) 0.21Comment #6
spiffl commentedComment #7
spiffl commentedSee attached patch from the issue fork, which also applies to
8.9.16.Comment #11
smustgrave commentedThis 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.