9 use Symfony\Component\Console\Command\Command;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Input\InputOption;
13 use Symfony\Component\Console\Output\OutputInterface;
44 $this->setName(
'i18n:pack')
45 ->setDescription(
'Saves language package');
46 $this->setDefinition([
48 self::INPUT_KEY_SOURCE,
49 InputArgument::REQUIRED,
50 'Path to source dictionary file with translations' 53 self::INPUT_KEY_LOCALE,
54 InputArgument::REQUIRED,
55 'Target locale for dictionary, for example "de_DE"' 60 InputOption::VALUE_REQUIRED,
61 'Save mode for dictionary' . PHP_EOL .
'- "replace" - replace language pack by new one' . PHP_EOL .
62 '- "merge" - merge language packages, by default "replace"',
66 self::INPUT_KEY_ALLOW_DUPLICATES,
68 InputOption::VALUE_NONE,
69 'Use the --allow-duplicates parameter to allow saving duplicates of translate.' .
70 ' Otherwise omit the parameter.' 81 $generator = ServiceLocator::getPackGenerator();
82 $mode = $input->getOption(self::INPUT_KEY_MODE);
83 if (
$mode !== self::MODE_MERGE &&
$mode !== self::MODE_REPLACE) {
84 throw new \InvalidArgumentException(
"Possible values for 'mode' option are 'replace' and 'merge'");
86 $locale = $input->getArgument(self::INPUT_KEY_LOCALE);
88 $input->getArgument(self::INPUT_KEY_SOURCE),
90 $input->getOption(self::INPUT_KEY_MODE),
91 $input->getOption(self::INPUT_KEY_ALLOW_DUPLICATES)
93 $output->writeln(
"<info>Successfully saved $locale language package.</info>");
94 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
execute(InputInterface $input, OutputInterface $output)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
const INPUT_KEY_ALLOW_DUPLICATES