Skip to content

Commit

Permalink
Merge pull request #10 from thokiller/thokiller-patch-1
Browse files Browse the repository at this point in the history
Bugfix Empty phrase en instanceof phrase
  • Loading branch information
lewisvoncken authored Nov 29, 2018
2 parents 19f4a7c + eea77d1 commit a3d1bd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Module/I18n/Dictionary/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function __construct(
ParserInterface $contextualParser,
Factory $factory,
Options\ResolverFactory $optionsResolver
) {
)
{
$this->parser = $parser;
$this->contextualParser = $contextualParser;
$this->factory = $factory;
Expand Down Expand Up @@ -96,7 +97,9 @@ public function generate($directory, $outputFilename, $withContext = false, $loc
throw new \UnexpectedValueException('No phrases found in the specified dictionary file.');
}
foreach ($phraseList as $phrase) {
$this->getDictionaryWriter($outputFilename, $delimiter, $enclosure)->write($phrase);
if ($phrase instanceof Phrase) {
$this->getDictionaryWriter($outputFilename, $delimiter, $enclosure)->write($phrase);
}
}
$this->writer = null;
}
Expand Down
17 changes: 10 additions & 7 deletions Module/I18n/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Please see LICENSE.txt for the full text of the OSL 3.0 license
*/

namespace Experius\MissingTranslations\Module\I18n;

/**
Expand Down Expand Up @@ -65,12 +66,14 @@ public function createDictionary()
*/
public function createPhrase(array $data)
{
return new Dictionary\Phrase(
$data['phrase'],
$data['translation'],
isset($data['context_type']) ? $data['context_type'] : null,
isset($data['context_value']) ? $data['context_value'] : null,
isset($data['quote']) ? $data['quote'] : null
);
if ("" != $data['phrase']) {
return new Dictionary\Phrase(
$data['phrase'],
$data['translation'],
isset($data['context_type']) ? $data['context_type'] : null,
isset($data['context_value']) ? $data['context_value'] : null,
isset($data['quote']) ? $data['quote'] : null
);
}
}
}

0 comments on commit a3d1bd3

Please sign in to comment.