protected function syncDoc($bundle, $key, $locale, $transFile)
 {
     $fullFilePath = $this->rootDir . '/' . $transFile;
     $document = file_get_contents($fullFilePath);
     $updatedAt = \DateTime::createFromFormat('U', filemtime($fullFilePath))->format('c');
     $result = $this->clientApiService->transDocSync($bundle, $key, $locale, $transFile, $document, $updatedAt);
     if ($result['result']) {
         if ($result['updated']) {
         } else {
             $updatedAt = new \DateTime($result['updatedAt']);
             copy($fullFilePath, $fullFilePath . '.' . $updatedAt->format('hms'));
             file_put_contents($fullFilePath, $result['message']);
             touch($fullFilePath, $updatedAt->getTimestamp());
         }
     } else {
         print_r($result);
         die;
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $yml = $this->input->getOption('yml');
     if (!$yml) {
         die('yml to upload is mandatory');
     }
     $this->init($input->getOption('address'), $input->getOption('port'));
     $config = $this->getContainer()->getParameter('translations_api');
     $managedLocales = $config['managed_locales'];
     $this->output->writeln(PHP_EOL . '<info>*** Uploading yml file ***</info>');
     $parts = explode('/', $yml);
     $lastPart = $parts[count($parts) - 1];
     preg_match("/^(?<catalog>[^\\.]*?)\\.(?<locale>[^\\.]*?)\\.yml\$/i", $lastPart, $match);
     $locale = isset($match['locale']) ? $match['locale'] : 'en';
     $catalog = isset($match['catalog']) ? $match['catalog'] : 'messages';
     preg_match("/(?<bundle>\\w*?Bundle)\\//i", $yml, $match);
     //$bundle  = $input->getOption('bundle');
     $bundle = isset($match['bundle']) ? $match['bundle'] : '';
     //var_dump($match, $locale, $catalog, $bundle); die;
     if (!$bundle) {
         die('Incorrect file, it must be in a Bundle folder to deduce its name and the filename');
     }
     $messages = $this->getYamlAsArray($yml);
     //print_r($localKeys); die;
     //$bundles = $this->clientApiService->getBundleIndex();
     //var_dump($bundles); die;
     // data para enviar al servidor
     $data = array();
     $date = date('c');
     $this->output->writeln(PHP_EOL . sprintf('<info>Processing catalog %s ...</info>', $catalog));
     $fileName = preg_replace("/.*\\/?src\\//", "", $yml);
     foreach ($messages as $key => $message) {
         $data[$key][$locale] = array('message' => $message, 'updatedAt' => $date, 'fileName' => $fileName, 'bundle' => $bundle);
     }
     //print_r($data); die;
     $this->output->writeln('uploadKeys("' . $catalog . '", $data)');
     $result = $this->clientApiService->uploadKeys($catalog, $data);
     $this->output->writeln('');
 }
 /**
  * FORMAT for the excel document
  * =============================
  *
  * one worksheet named as the language you want to import
  * one workseeht named "key" with the following format
  *   rowX colA ColB
  *     1   [1]  (1)   => (1) var substitution, [1] style substitution
  *
  * the reason for this "key system" is that normally translators haven't to translate the html labels and variables and this is a way to assure this
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $file = $input->getArgument('excel');
     $language = $input->getArgument('language');
     $approved = (bool) $input->getOption('approved');
     //$this->init($input->getOption('address'), $input->getOption('port'));
     $phpExcel = $container->get('phpexcel');
     /** @var \PHPExcel $excel */
     $excel = $phpExcel->createPHPExcelObject();
     $excel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
     $newSheet = clone $excel->getActiveSheet();
     $excel->setActiveSheetIndex(0)->setTitle($language)->setCellValue('A1', "key (don't translate)")->setCellValue('B1', $language . " (don't translate)")->setCellValue('C1', 'New language (here the translation)');
     $excel->addSheet($newSheet);
     $excel->setActiveSheetIndex(1)->setTitle('keys')->setCellValue('A4', 'Miscellaneous glyphs')->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
     $excel->getActiveSheet()->setCellValue('A8', "Hello\nWorld");
     $excel->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
     $excel->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true);
     $objWriter = new \PHPExcel_Writer_Excel5($excel);
     $objWriter->save($file);
     die('OK');
     $keySheet = $excel->getSheetByName('key');
     $key = array();
     //array_flip(json_decode($keySheet->getCell('A1'), true));
     foreach ($keySheet->getRowIterator() as $row) {
         var_dump($row->getRowIndex());
         $rowNum = $row->getRowIndex();
         $cellIterator = $row->getCellIterator();
         $cellIterator->setIterateOnlyExistingCells(false);
         // Loop all cells, even if it is not set
         foreach ($cellIterator as $cell) {
             /** @var \PHPExcel_Cell $cell */
             $cellValue = $cell->getCalculatedValue();
             switch ($cell->getColumn()) {
                 case "A":
                     $index = "[{$rowNum}]";
                     break;
                 case "B":
                     $index = "({$rowNum})";
                     break;
             }
             if (!is_null($cellValue)) {
                 $key[$index] = $cellValue;
             }
         }
     }
     // get the worksheet that match its title with language
     $worksheet = $excel->getSheetByName($language);
     $output->writeln("\n<comment>Worksheet - " . $worksheet->getTitle() . "</comment>");
     $localData = array();
     foreach ($worksheet->getRowIterator() as $row) {
         /** @var \PHPExcel_Worksheet_Row $row */
         $index = $row->getRowIndex();
         $rowNum = $row->getRowIndex();
         $keyName = $this->getCellValue($worksheet, "A{$rowNum}");
         $reference = $this->getCellValue($worksheet, "B{$rowNum}");
         $message = $this->getCellValue($worksheet, "C{$rowNum}");
         $substituted = $this->substitute($key, $message, $reference);
         //$output->writeln(sprintf("<comment>$index</comment>\t<info>%s</info> => %s => <comment>%s</comment>", $keyName, $reference, $substituted));
         $localData[$keyName] = $substituted;
     }
     // download translations from server
     $result = $this->clientApiService->getCatalogIndex();
     if ($result['result']) {
         $catalogs = $result['catalogs'];
     } else {
         die('error getting catalogs');
     }
     $tempData = array();
     foreach ($catalogs as $catalog) {
         $output->writeln(PHP_EOL . sprintf('<info>Processing "%s" catalog ...</info>', $catalog));
         $result = $this->clientApiService->downloadKeys($catalog);
         //var_dump($result); die;
         file_put_contents('/tmp/' . $catalog . '.json', json_encode($result));
         $bundles = $result['bundles'];
         //var_dump($result['data']['Bad credentials']); die;
         foreach ($result['data'] as $key => $data) {
             foreach ($data as $locale => $messageData) {
                 if ($locale == $language && isset($localData[$key])) {
                     $tempData[$key][$catalog] = array_merge($messageData, array('new' => $localData[$key]));
                     //$output->writeln(sprintf("\t|-- key %s:%s/%s ... ", $catalog, $key, $locale));
                     echo '.';
                     //$fileName = isset($messageData['fileName']) ? $messageData['fileName'] : '';
                 }
             }
         }
     }
     //print_r($tempData);
     $output->writeln("\nAnalysing the result of the match process...\n");
     $count = 0;
     // data to send to translations server
     $data = array();
     // this date guarantees that the data sent to server forces to update key
     $date = date('c');
     // get the key that are repeated
     foreach ($tempData as $key => $restData) {
         if (count($restData) > 1) {
             $output->writeln("\tthe key {$key} is in more that one catalog");
         }
         foreach ($restData as $catalog => $messageData) {
             if (!empty($messageData['new']) && $messageData['message'] != $messageData['new']) {
                 //var_dump($messageData); die;
                 $data[$key][$language] = array('approved' => $approved, 'message' => $messageData['new'], 'updatedAt' => $date, 'fileName' => isset($messageData['fileName']) ? $messageData['fileName'] : "", 'bundle' => isset($bundles[$key]) ? $bundles[$key] : "");
                 $output->writeln("the key {$key} needs to be updated");
                 $count++;
             }
         }
     }
     $total = count($localData);
     $output->writeln("\nfound {$count} keys that need to be updated from a total of {$total} keys that have the file to process\n");
     if ($count) {
         //ld($data);
         $output->writeln('uploadKeys("' . $catalog . '", $data)');
         $result = $this->clientApiService->uploadKeys($catalog, $data);
         //var_dump($result);
     }
     $output->writeln("\n done!");
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $ymlOptions = array('regenerate' => false, 'backup' => false, 'blank' => false);
     $yml = $this->input->getOption('yml');
     if ($yml) {
         $aux = explode(",", $yml);
         if (count($aux)) {
             foreach ($aux as $option) {
                 $ymlOptions[$option] = true;
             }
         }
     }
     if (count($ymlOptions) != 3) {
         var_dump($ymlOptions);
         die('Sorry, but you can use only regenerate,blank and backup with --yml option');
     }
     $this->init($input->getOption('address'), $input->getOption('port'));
     $config = $this->getContainer()->getParameter('translations_api');
     $managedLocales = $config['managed_locales'];
     $this->output->writeln(PHP_EOL . '<info>*** Syncing translations ***</info>');
     /**
      * uploading local catalog keys (from local table) to remote server
      */
     if ($input->getOption('upload-first') == 'yes') {
         $catalogs = $this->translationsRepository->getCatalogs();
         foreach ($catalogs as $catalog) {
             // data para enviar al servidor
             $data = array();
             $this->output->writeln(PHP_EOL . sprintf('<info>Processing catalog %s ...</info>', $catalog));
             /** @var Translation[] $messages */
             $messages = $this->translationsRepository->findBy(array('domain' => $catalog));
             foreach ($messages as $message) {
                 $key = $message->getKey();
                 $locale = $message->getLocale();
                 $bundle = $message->getBundle();
                 $fileName = $message->getFile();
                 $data[$key][$locale] = array('message' => $message->getMessage(), 'updatedAt' => $message->getUpdatedAt()->format('c'), 'fileName' => $message->getFile(), 'bundle' => $message->getBundle());
             }
             $this->output->writeln('uploadKeys("' . $catalog . '", $data)');
             $result = $this->clientApiService->uploadKeys($catalog, $data);
         }
     }
     /**
      * download the remote catalogs and integrate into local table (previously truncate local table)
      */
     // truncate local translations table
     $this->translationsRepository->truncateTranslations();
     $result = $this->clientApiService->getCatalogIndex();
     if ($result['result']) {
         $catalogs = $result['catalogs'];
     } else {
         die('error getting catalogs');
     }
     foreach ($catalogs as $catalog) {
         $this->output->writeln(PHP_EOL . sprintf('<info>Processing catalog %s ...</info>', $catalog));
         $result = $this->clientApiService->downloadKeys($catalog);
         file_put_contents(sys_get_temp_dir() . DIRECTORY_SEPARATOR . $catalog . '.json', json_encode($result));
         $bundles = $result['bundles'];
         foreach ($result['data'] as $key => $data) {
             foreach ($data as $locale => $messageData) {
                 echo '.';
                 $fileName = isset($messageData['fileName']) ? $messageData['fileName'] : '';
                 $trans = Translation::newFromArray($catalog, $key, $locale, $messageData, $bundles[$key], $fileName);
                 $this->em->persist($trans);
             }
         }
     }
     $this->output->writeln(PHP_EOL . '<info>Flushing to DB ...</info>');
     $this->em->flush();
     /**
      * regeneration of local .yml files if user wants
      */
     /** @var DialogHelper $dialog */
     $dialog = $this->getHelper('dialog');
     if ($ymlOptions['regenerate']) {
         $bundles = $this->translationsRepository->getBundles();
         foreach ($bundles as $bundle) {
             if (!$bundle) {
                 continue;
             }
             $keys = array();
             $filenames = array();
             $scheme = "";
             // in order to deduce filename from other keys
             $translations = $this->translationsRepository->getKeysByBundle($bundle);
             foreach ($translations as $translation) {
                 $locale = $translation->getLocale();
                 $file = $translation->getFile();
                 if ($file && $locale && !$scheme) {
                     $scheme = str_replace(".{$locale}.", ".%s.", $file);
                     break;
                 }
             }
             foreach ($translations as $translation) {
                 $locale = $translation->getLocale();
                 $file = $translation->getFile();
                 if ($locale && !$file && $scheme) {
                     $file = sprintf($scheme, $locale);
                 }
                 if ($file && $locale) {
                     if (!isset($filenames[$locale])) {
                         $filenames[$locale] = $file;
                     }
                     $keys[$locale][$translation->getKey()] = $translation->getMessage();
                 }
             }
             foreach ($filenames as $locale => $file) {
                 $this->output->writeln(sprintf('Generating <info>"%s"</info> ...', $file));
                 $subKeys = $keys[$locale];
                 $file = dirname($this->rootDir) . '/src/' . $file;
                 if ($ymlOptions['blank']) {
                     foreach ($subKeys as $key => $value) {
                         if (!$value) {
                             $subKeys[$key] = $key;
                         }
                     }
                 }
                 if ($ymlOptions['backup'] && file_exists($file)) {
                     copy($file, $file . '.' . date('U'));
                 }
                 @mkdir(dirname($file), 0777, true);
                 file_put_contents($file, ArrayTools::prettyYamlDump($subKeys));
             }
         }
     }
     /**
      * erasing cached translations files
      */
     $this->output->writeln(PHP_EOL . '<info>Clearing SF cache ...</info>');
     $finder = new Finder();
     $finder->files()->in($this->rootDir . "/cache")->name('*');
     foreach ($finder as $file) {
         $fileFull = $file->getRealpath();
         //$relativePath = $file->getRelativePath();
         $fileName = $file->getRelativePathname();
         if (preg_match('!/translations/.+$!i', $fileName)) {
             $this->output->writeln('removing ' . $fileName);
             unlink($file);
         }
     }
     $this->output->writeln('');
 }
 /**
  * FORMAT for the excel document
  * =============================
  *
  * one worksheet named as the language you want to import
  * one workseeht named "key" with the following format
  *   rowX colA ColB
  *     1   [1]  (1)   => (1) var substitution, [1] style substitution
  *
  * the reason for this "key system" is that normally translators haven't to translate the html labels and variables and this is a way to assure this
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $file = $input->getArgument('excel');
     $language = $input->getArgument('language');
     $approved = (bool) $input->getOption('approved');
     $this->init($input->getOption('address'), $input->getOption('port'));
     $phpExcel = $container->get('phpexcel');
     /** @var \PHPExcel $excel */
     $excel = $phpExcel->createPHPExcelObject($file);
     $keySheet = $excel->getSheetByName('key');
     $key = array();
     //array_flip(json_decode($keySheet->getCell('A1'), true));
     foreach ($keySheet->getRowIterator() as $row) {
         $rowNum = $row->getRowIndex();
         $cellIterator = $row->getCellIterator();
         $cellIterator->setIterateOnlyExistingCells(false);
         // Loop all cells, even if it is not set
         foreach ($cellIterator as $cell) {
             /** @var \PHPExcel_Cell $cell */
             $cellValue = $cell->getCalculatedValue();
             switch ($cell->getColumn()) {
                 case "A":
                     $index = "[{$rowNum}]";
                     break;
                 case "B":
                     $index = "({$rowNum})";
                     break;
             }
             if (!is_null($cellValue)) {
                 $key[$index] = $cellValue;
             }
         }
     }
     // get the worksheet that match its title with language
     $worksheet = $excel->getSheetByName($language);
     $output->writeln("\n<comment>Worksheet - " . $worksheet->getTitle() . "</comment>");
     $localData = array();
     foreach ($worksheet->getRowIterator() as $row) {
         /** @var \PHPExcel_Worksheet_Row $row */
         $index = $row->getRowIndex();
         $rowNum = $row->getRowIndex();
         $keyName = $this->getCellValue($worksheet, "A{$rowNum}");
         $reference = $this->getCellValue($worksheet, "B{$rowNum}");
         $message = $this->getCellValue($worksheet, "C{$rowNum}");
         $substituted = $this->substitute($key, $message, $reference);
         //$output->writeln(sprintf("<comment>$index</comment>\t<info>%s</info> => %s => <comment>%s</comment>", $keyName, $reference, $substituted));
         $localData[$keyName] = $substituted;
     }
     // download translations from server
     $result = $this->clientApiService->getCatalogIndex();
     if ($result['result']) {
         $catalogs = $result['catalogs'];
     } else {
         die('error getting catalogs');
     }
     $tempData = array();
     foreach ($catalogs as $catalog) {
         $output->writeln(PHP_EOL . sprintf('<info>Processing "%s" catalog ...</info>', $catalog));
         $result = $this->clientApiService->downloadKeys($catalog);
         file_put_contents('/tmp/' . $catalog . '.json', json_encode($result));
         $bundles = $result['bundles'];
         foreach ($result['data'] as $key => $data) {
             foreach ($data as $locale => $messageData) {
                 if ($locale == $language && isset($localData[$key])) {
                     $tempData[$key][$catalog] = array_merge($messageData, array('new' => $localData[$key]));
                     //$output->writeln(sprintf("\t|-- key %s:%s/%s ... ", $catalog, $key, $locale));
                     echo '.';
                     //$fileName = isset($messageData['fileName']) ? $messageData['fileName'] : '';
                 }
             }
         }
     }
     $output->writeln("\nAnalysing the result of the match process...\n");
     $count = 0;
     // data to send to translations server
     $data = array();
     // this date guarantees that the data sent to server forces to update key
     $date = date('c');
     $output->writeln("found " . count($localData) . " keys in excel\n");
     // get the key that are repeated
     foreach ($tempData as $key => $restData) {
         if (count($restData) > 1) {
             $output->writeln(sprintf("\tthe key %s is in more that one catalog", $key));
         }
         foreach ($restData as $catalog => $messageData) {
             if (!empty($messageData['new']) && $messageData['message'] != $messageData['new']) {
                 //var_dump($messageData); die;
                 $data[$catalog][$key][$language] = array('approved' => $approved, 'message' => $messageData['new'], 'updatedAt' => $date, 'fileName' => isset($messageData['fileName']) ? $messageData['fileName'] : "", 'bundle' => isset($bundles[$key]) ? $bundles[$key] : "");
                 $output->writeln("the key {$key} needs to be updated");
                 $count++;
             }
         }
     }
     $total = count($localData);
     $output->writeln("\nfound {$count} keys that need to be updated from a total of {$total} keys that had the file to be processed\n");
     //var_dump($data); die;
     if ($count) {
         foreach ($data as $catalog => $restData) {
             //ld($data);
             //$output->writeln('uploadKeys("' . $catalog . '", $data)');
             $result = $this->clientApiService->uploadKeys($catalog, $restData);
             //var_dump($result);
         }
     }
     $output->writeln("\n done!");
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $this->init();
     $verbose = (bool) $input->getOption('verbose');
     $bundleToExtract = $input->getOption('bundle');
     $minWords = intval($input->getOption('min-words') ?: 0);
     $this->output->writeln('<info>*** Discovering new keys in php, twig and js files ***</info>');
     $fileNames = array();
     $keys = array();
     $idx = 0;
     $numKeys = 0;
     $patterns = array('*.twig' => '/(["\'])(?<trans>(?:\\\\1|(?!\\1).)+?)\\1\\s*\\|\\s*trans/i', '*.html.twig' => '/\\.trans\\s*\\(\\s*(["\'])(?<trans>(?:\\\\1|(?!\\1).)+?)\\1/i', '*.php' => '/trans\\s*\\(\\s*(["\'])(?<trans>(?:\\\\1|(?!\\1).)+?)\\1\\s*\\)/i', '*Type.php' => '/([\'"])label\\1\\s*=>\\s*([\'"])(?<trans>(?:\\\\2|(?!\\2).)+?)\\2/', '*.js' => '/trans.getTranslation\\s*\\(\\s*(["\'])(?<trans>(?:\\\\1|(?!\\1).)+?)\\1\\s*\\)/i');
     $folders = array($this->srcDir . '/app', $this->srcDir . '/src');
     $keyInfo = array();
     foreach ($patterns as $filePattern => $exrPattern) {
         foreach ($folders as $folder) {
             if ($verbose) {
                 $output->writeln($folder);
             }
             $finder = new Finder();
             $files = $finder->in($folder)->name($filePattern)->files();
             /** @var SplFileInfo[] $files */
             foreach ($files as $file) {
                 $fileName = $folder . '/' . $file->getRelativePathname();
                 if (strpos($fileName, $folder . "/cache") === 0) {
                     //$output->writeln(sprintf("ignored <comment>%s</comment>", $file));
                     continue;
                 }
                 if (preg_match("/\\/(?P<bundle>.*Bundle)\\//U", $file->getRelativePathname(), $match)) {
                     $bundleName = $match['bundle'];
                 } else {
                     $bundleName = "*app";
                 }
                 if (!$bundleToExtract || $bundleToExtract == $bundleName) {
                     $fileContents = file_get_contents($fileName);
                     if (preg_match_all($exrPattern, $fileContents, $matches)) {
                         if ($verbose) {
                             $output->writeln(sprintf("<info>%s</info>", $file));
                         }
                         $fileNames[$bundleName] = $file->getRelativePathname();
                         if (!isset($keys[$bundleName])) {
                             if ($verbose) {
                                 $output->writeln($bundleName);
                             }
                             $keys[$bundleName] = array();
                         }
                         $keys[$bundleName] = array_merge_recursive($keys[$bundleName], $matches["trans"]);
                         foreach ($matches['trans'] as $currentKey) {
                             $keyInfo[$bundleName][$currentKey] = $file->getRelativePathname();
                         }
                         $numKeys += count($matches['trans']);
                     }
                     $idx++;
                 }
             }
         }
     }
     $output->writeln(sprintf("Total %d files examined, and found key translations in %d files", $idx, count($fileNames)));
     $output->writeln(sprintf("Total %d keys extracted (%d)", $numKeys, count($keys, COUNT_RECURSIVE)));
     // get all the translations from the local DB
     $sortedKeys = array();
     /** @var Translation[] $localKeys */
     $localKeys = $this->translationRepository->findAll();
     foreach ($localKeys as $localKey) {
         $bundle = $localKey->getBundle();
         $keyName = $localKey->getKey();
         $sortedKeys[$keyName][$bundle] = true;
     }
     unset($localKeys);
     $localSortedKeys = array();
     /** @var CandidateKey[] $candidates */
     $candidates = array();
     // find keys thar are in files but not in db
     foreach ($keys as $bundle => $keyArray) {
         foreach ($keyArray as $key) {
             if (!isset($sortedKeys[$key])) {
                 if (!$minWords || $minWords - 1 <= substr_count($key, ".")) {
                     $file = $keyInfo[$bundle][$key];
                     $candidates[] = new CandidateKey($bundle, $file, $key);
                     //$output->writeln(sprintf("file local key <info>%s</info>[<comment>%s</comment>] not found in DB, file %s", $bundle, $key, $file));
                 }
             }
             $localSortedKeys[$bundle][$key] = true;
         }
     }
     //        // find keys that are in db but not used in files
     //        foreach($sortedKeys as $bundle=>$keyArray){
     //
     //            //var_dump($keyArray);
     //            foreach($keyArray as $key=>$void){
     //
     //                if(!isset($localSortedKeys[$bundle][$key])){
     //
     //                    $output->writeln(sprintf("db key <info>%s</info>[<comment>%s</comment>] not used in local files", $bundle, $key));
     //                    //var_dump($localSortedKeys[$bundle]);
     //                    //die;
     //                }
     //
     //            }
     //
     //        }
     if (!count($candidates)) {
         $output->writeln("Congratulations!, you have all the keys synchronized");
         exit;
     }
     $output->writeln("Check the possible candidate keys to upload to server");
     foreach ($candidates as $candidate) {
         $output->writeln(sprintf("key <info>%s</info>[<comment>%s</comment>] not found in local DB, file %s", $candidate->getKey(), $candidate->getBundle(), $candidate->getFile()));
     }
     $output->writeln(PHP_EOL . '<info>Have you been synchronized your translations with the sync command?</info>' . PHP_EOL);
     /** @var DialogHelper $dialog */
     $dialog = $this->getHelper('dialog');
     if ($dialog->askConfirmation($output, '<question>Confirm that you want to upload the previous keys to server ?</question>', false)) {
         $catalog = $dialog->ask($output, 'Name of catalog in which to integrate new keys [messages]:', 'messages');
         $data = array();
         $date = new \DateTime();
         $config = $this->getContainer()->getParameter('translations_api');
         $managedLocales = $config['managed_locales'];
         foreach ($candidates as $candidate) {
             $key = $candidate->getKey();
             $bundle = $candidate->getBundle();
             $fileName = $candidate->getFile();
             if (preg_match('|^(?<prefix>\\w+)/' . $bundle . '/|', $fileName, $matches)) {
                 if ($matches['prefix']) {
                     $prefix = $matches['prefix'];
                     foreach ($managedLocales as $locale) {
                         $data[$key][$locale] = array('message' => '', 'updatedAt' => $date->format('c'), 'fileName' => $prefix . '/' . $this->genFileFromBundleAndLocale($bundle, $catalog, $locale), 'bundle' => $bundle);
                     }
                 }
             }
         }
         //$this->output->writeln('uploadKeys("' . $catalog . '", $data)');
         //var_dump($data); //die;
         $this->clientApiService->init();
         $result = $this->clientApiService->uploadKeys($catalog, $data);
     }
     $output->writeln('You must now to synchronize your translations with the sync command!');
 }