/**
  * Index action
  *
  * @param \TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $languageSelectionForm
  * @param mixed $extensions Extensions to show in form
  * @return void
  * @ignorevalidation $languageSelectionForm
  * @ignorevalidation $extensions
  */
 public function indexAction(\TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $languageSelectionForm = NULL, $extensions = NULL)
 {
     if ($languageSelectionForm === NULL) {
         $languageSelectionForm = $this->objectManager->get('TYPO3\\CMS\\Lang\\Domain\\Model\\LanguageSelectionForm');
         $languageSelectionForm->setLanguages($this->languageRepository->findAll());
         $languageSelectionForm->setSelectedLanguages($this->languageRepository->findSelected());
     }
     if (empty($extensions)) {
         $extensions = $this->extensionRepository->findAll();
     }
     $this->view->assign('languageSelectionForm', $languageSelectionForm);
     $this->view->assign('extensions', $extensions);
 }
 /**
  * Fetch all translations for given locale
  *
  * @param array $data The request data
  * @return void
  */
 public function updateLanguageAction(array $data)
 {
     $response = array('success' => FALSE, 'progress' => 0);
     if (!empty($data['locale'])) {
         $extension = $this->extensionRepository->findOneByOffset((int) $data['count']);
         if (!empty($extension)) {
             $allCount = (int) $this->extensionRepository->countAll();
             $offset = (int) $data['count'];
             $extensionKey = $extension->getKey();
             $result = $this->translationService->updateTranslation($extensionKey, $data['locale']);
             $progress = round(($offset + 1) * 100 / $allCount, 2);
             if (empty($result[$extensionKey][$data['locale']]['error'])) {
                 $this->registryService->set($data['locale'], $GLOBALS['EXEC_TIME']);
                 $response = array('success' => TRUE, 'result' => $result, 'timestamp' => $GLOBALS['EXEC_TIME'], 'progress' => $progress > 100 ? 100 : $progress);
             }
         }
     }
     $this->view->assign('response', $response);
 }
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     $languages = $this->languageRepository->findAll();
     $selectedLanguages = $this->languageRepository->findSelected();
     $extensions = $this->extensionRepository->findAll();
     if ($this->request->hasArgument('updateResult')) {
         $extensions = $this->mergeUpdateResult($extensions, $this->request->getArgument('updateResult'));
     }
     $this->view->assign('languages', $languages);
     $this->view->assign('selectedLanguages', $selectedLanguages);
     $this->view->assign('extensions', $extensions);
 }
 /**
  * Fetch all translations for given locale
  *
  * @param array $data The request data
  * @return void
  */
 public function updateLanguageAction(array $data)
 {
     $numberOfExtensionsToUpdate = 10;
     $response = array('success' => false, 'progress' => 0);
     $progress = 0;
     if (!empty($data['locale'])) {
         $allCount = 0;
         for ($i = 0; $i < $numberOfExtensionsToUpdate; $i++) {
             $offset = (int) $data['count'] * $numberOfExtensionsToUpdate + $i;
             /** @var Extension $extension */
             $extension = $this->extensionRepository->findOneByOffset($offset);
             if (empty($extension)) {
                 // No more extensions to update
                 break;
             }
             if ($allCount === 0) {
                 $allCount = (int) $this->extensionRepository->countAll();
             }
             $extensionKey = $extension->getKey();
             $result = $this->translationService->updateTranslation($extensionKey, $data['locale']);
             $progress = round(($offset + 1) * 100 / $allCount, 2);
             $response['result'][$data['locale']][$extensionKey] = $result[$data['locale']];
             if (empty($result[$extensionKey][$data['locale']]['error'])) {
                 $response['success'] = true;
             } else {
                 // Could not update an extension, stop here!
                 $response['success'] = false;
                 break;
             }
         }
     }
     if ($response['success']) {
         $this->registryService->set($data['locale'], $GLOBALS['EXEC_TIME']);
         $response['timestamp'] = $GLOBALS['EXEC_TIME'];
         $response['progress'] = $progress > 100 ? 100 : $progress;
     }
     $this->view->assign('response', $response);
     // Flush language cache
     GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
 }