Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Under special cicumstances (that I admit I do not fully understand) an empty string can be added to the locale tables. This is in general not a problem, but the exported PO file will be regarded as invalid by the gettext programms. Attached patch fixes this by not exporting an empty source string. It also changes some double to single quotes.
Comment | File | Size | Author |
---|---|---|---|
#5 | drupal_51 | 1.64 KB | killes@www.drop.org |
locale_12.patch | 4.33 KB | killes@www.drop.org | |
Comments
Comment #1
Dries CreditAttribution: Dries commentedGuess what? I prefer not to insert empty strings in first place. :)
There is only one query that inserts data in the
locales_source
table. If you look at thelocale()
function, you see that this can happen when an empty string is passed tot()
(and thus tolocale()
).Comment #2
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedGuess what? I anticipated your answer... ;)
However, even if we'd be able to weed out all instances of insertions of the empty string as a source string all currently existing locale databases are likely to be already polluted and thus all exported PO(T) files will be invalid. Further, this kind of malformatting also triggers the "header broken" error that you didn't like. The reason is that the empty source string is reserved for the header.
So please apply this patch and I'll follow up with a better error message for that error.
Comment #3
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedOne reason for the empty string being inserted is that some contrib modules translate user input (which can be empty) in order to make them usable for multiple language setups.
Comment #4
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedHere is a patch that does the checking in the php. Maybe you prefer it done this way. In any case, the solution to clean up the PO files before creating them is superior to checking every string if it might be empty while calling t(). t() is called very often, PO files are seldomly generated.
Comment #5
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedComment #6
Dries CreditAttribution: Dries commentedCommitted to HEAD.
Comment #7
(not verified) CreditAttribution: commented