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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dries’s picture

Guess 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 the locale() function, you see that this can happen when an empty string is passed to t() (and thus to locale()).

killes@www.drop.org’s picture

Guess 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.

killes@www.drop.org’s picture

One 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.

killes@www.drop.org’s picture

Here 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.

killes@www.drop.org’s picture

FileSize
1.64 KB
Dries’s picture

Committed to HEAD.

Anonymous’s picture