Description
Using a clean 2.0.2 CE, I created an language pack doing the following in the magento root directory:
./bin/magento i18n:collect-phrases -o var/tmp/de_DE.csv -m ./
./bin/magento i18n:pack --allow-duplicates var/tmp/de_DE.csv app/i18n/DynamoGold/de_de/ de_DE
This results in an (silent) error. I found the following in the php_error.log:
[05-Feb-2016 13:59:31 UTC] PHP Parse error: syntax error, unexpected '' is not found'' (T_CONSTANT_ENCAPSED_STRING), expecting ';' in /Applications/MAMP/htdocs/BIGO/shop2.birkengold.com/setup/src/Magento/Setup/Module/I18n/Dictionary/Phrase.php(278) : eval()'d code on line 1
It breaks when parsing line 44 of var/tmp/de_DE.csv:
"Entity type model '%1' is not found","Entity type model '%1' is not found",module,Magento_AdvancedPricingImportExport
The error seems to occur when single quotes are not correctly escaped. I think this happens already during i18n:collect-phrase, but I am not sure.
I fixed this by changing setup/src/Magento/Setup/Module/i18n/Disctionary/Phrase.php to
private function getCompiledString($string) {
$encloseQuote = $this->getQuote() == Phrase::QUOTE_DOUBLE ? Phrase::QUOTE_DOUBLE : Phrase::QUOTE_SINGLE;
//find all occurrences of ' and ", with no \ before it.
preg_match_all('/(?<!\)['"]/', $string, $matches);
if (count($matches[0]) % 2 !== 0) {
$string = addslashes($string);
}
$escapedString = str_replace("'", "'", $string);
$escapedString = str_replace("'", "'", $escapedString);
$evalString = 'return ' . $encloseQuote . $escapedString. $encloseQuote . ';';
$result = @eval($evalString);
return is_string($result) ? $result : $string;
}
Please look at the two lines before $evalString = ...
This is obvisousely a dirty hack, but someone needs to take care of this since it is currently not possible to create language packs even on a Magento 2 CE installation out of the box