When exporting po file templates, with the default option (Source text only, no translation) I've found these issues:

1. We get duplicated strings.
To get this, you just need to add two languages and add a translation of the same string for each.

Looking into the query, it seems either there's one DISTINCT missing or one join not needed (we wouln't need to join locales_target here).

2. Then, reloading the page, we get multiple warnings like these:

Warning: addcslashes() expects parameter 1 to be string, array given in Drupal\Component\Gettext\PoItem->formatString() (line 269 of core/lib/Drupal/Component/Gettext/PoItem.php).

I suspect this last one is related to the singular / plural handling in PoItem class.

Files: 
CommentFileSizeAuthor
#8 localeExport.patch2.29 KBdroplet
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 66,915 pass(es).
[ View ]

Comments

Issue tags:+D8MI, +language-ui

Adding D8MI tags.

The 'duplicated strings' issue will be fixed by #1785086: Introduce a generic API for interface translation strings

So, duplicated strings fixed, now there's only the export warnings.

Title:Duplicated strings and warnings when exporting templates: addcslashes() expects parameter 1 to be stringWarnings when exporting templates: addcslashes() expects parameter 1 to be string

Updating title to match the issue scope.

Just to notice that the problem Jose Reyero describes still occurs – in the end of the exportation of a .po file, I get this message:

Warning: addcslashes() expects parameter 1 to be string, array given in Drupal\Component\Gettext\PoItem->formatString() (line 269 of core/lib/Drupal/Component/Gettext/PoItem.php).

Oh, sounds like an issue with plural exports? can you look in the exported .po file if there are msgid and msgid_plural items that are empty? Or suspicious in some way?

We checked with Gábor Hojtsy the msgid and msgid_plural items and they seemed to be normal.

I wanted to add that I had this problem in these conditions:
- I installed the site in French
- on admin/config/regional/translate I translated some strings from English to French
- on admin/config/regional/translate/export I exported these translations on a .po file
- I go the error message

The problem doesn't occur when
- I install the site in English
- I don't translate anything and on admin/config/regional/translate/export I have this message: "No language available. The export will only contain source strings."
- I click anyway on the "export" link and get the drupal.pot file
- I don't have the error message

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new2.29 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 66,915 pass(es).
[ View ]

Also, symfony required php_fileinfo ext to output to files. Is there somewhere we can/should document it ?