48 public function run(
string $path =
'',
bool $runBefore =
false): array
50 if (empty($path) || !\preg_match(
"#(.+\/lang)(\/?\w*)#", $path, $matches))
55 'STATUS' => Translate\Controller\STATUS_COMPLETED
58 if (!Translate\
IO\Path::isLangDir($path))
63 'STATUS' => Translate\Controller\STATUS_COMPLETED
72 $this->langFilePath = Translate\IO\Path::replaceLangId($path,
'#LANG_ID#');
75 foreach ($this->languages as $langId)
77 $langRelPath = Translate\IO\Path::replaceLangId($path, $langId);
78 $langFullPath = Translate\IO\Path::tidy(self::$documentRoot .
'/' . $langRelPath);
80 if (self::$useTranslationRepository && \in_array($langId, self::$translationRepositoryLanguages))
82 $langFullPath = Main\Localization\Translation::convertLangPath($langFullPath, $langId);
85 $fullPaths[$langId] = $langFullPath;
88 $this->data = $this->
mergeLangFiles($this->langFilePath, $fullPaths, $this->collectUntranslated);
90 if ($this->isNewProcess)
92 $this->totalItems = (int)count($this->data);
93 $this->processedItems = 0;
95 if ($this->totalItems > 0)
98 $csvFile = $this->createExportTempFile($this->exportFileName);
99 $this->exportFilePath = $csvFile->getPhysicalPath();
100 $this->exportFileSize = $csvFile->getSize();
102 if ($this->appendSamples)
105 $sampleFile = $this->createExportTempFile($this->samplesFileName);
106 $this->samplesFilePath = $sampleFile->getPhysicalPath();
107 $this->samplesFileSize = $sampleFile->getSize();
113 'STATUS' => $this->totalItems > 0
114 ? Translate\Controller\STATUS_PROGRESS
115 : Translate\Controller\STATUS_COMPLETED,
116 'PROCESSED_ITEMS' => 0,
123 return $this->
performStep(
'runExporting', [
'path' => $path]);