69 $allowDuplicates =
false 71 $locale = $this->factory->createLocale($locale);
72 $dictionary = $this->dictionaryLoader->load($dictionaryPath);
74 $phrases = $dictionary->getPhrases();
75 if (!is_array($phrases) || !count($phrases)) {
76 throw new \UnexpectedValueException(
'No phrases have been found by the specified path.');
79 if (!$allowDuplicates && ($duplicates = $dictionary->getDuplicates())) {
80 throw new \RuntimeException(
81 "Duplicated translation is found, but it is not allowed.\n" 82 . $this->createDuplicatesPhrasesError($duplicates)
86 $this->packWriter->writeDictionary($dictionary, $locale,
$mode);
95 protected function createDuplicatesPhrasesError($duplicates)
98 foreach ($duplicates as $phrases) {
100 $phrase = $phrases[0];
102 "The phrase \"%s\" is translated in %d places.\n",
103 $phrase->getPhrase(),
__construct(Dictionary\Loader\FileInterface $dictionaryLoader, Pack\WriterInterface $packWriter, Factory $factory)
generate( $dictionaryPath, $locale, $mode=WriterInterface::MODE_REPLACE, $allowDuplicates=false)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode