2namespace Bitrix\Translate\Controller\Export;
6use Bitrix\Main\Localization\Loc;
18 private string $seekPhraseCode =
'';
20 private array $data = [];
22 private string $langFilePath =
'';
33 Loc::loadLanguageFile(__DIR__ .
'/exportaction.php');
75 foreach ($this->languages as $langId)
80 if (self::$useTranslationRepository && \in_array($langId, self::$translationRepositoryLanguages))
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
116 'PROCESSED_ITEMS' => 0,
137 $csvFile->openWrite(
Main\
IO\FileStreamOpenMode::APPEND);
139 if ($this->appendSamples)
143 $samplesFile->openWrite(
Main\
IO\FileStreamOpenMode::APPEND);
146 $currentLangId = Loc::getCurrentLang();
148 $processedItemCount = 0;
149 foreach ($this->data as
$code => $row)
151 if (!empty($this->seekPhraseCode))
153 if (
$code == $this->seekPhraseCode)
155 $this->seekPhraseCode =
'';
160 $csvFile->put(\array_values($row));
164 && !empty($row[$currentLangId])
165 && mb_strlen($row[$currentLangId]) < $this->maxSampleSourceLength
168 $samples = $this->findSamples(
169 $row[$currentLangId],
173 $this->samplesRestriction
175 foreach ($samples as $sample)
177 $samplesFile->put(\array_values($sample));
178 $this->exportedSamplesCount ++;
182 $this->exportedPhraseCount ++;
183 $processedItemCount ++;
187 $this->seekPhraseCode =
$code;
192 $this->processedItems += $processedItemCount;
194 $this->exportFileSize = $csvFile->getSize();
197 if ($this->appendSamples)
199 $this->samplesFileSize = $samplesFile->getSize();
200 $samplesFile->close();
216 if ($csvFile->hasErrors())
218 $errors = $csvFile->getErrors();
221 if ($err->getCode() == Translate\IO\CsvFile::ERROR_32K_FIELD_LENGTH)
223 $result[
'WARNING'] = Loc::getMessage(
'TR_EXPORT_ERROR_32K_LENGTH');
static convertLangPath($langFile, $language)
int $exportedSamplesCount
configureExportCsvFile(Translate\IO\CsvFile $csvFile)
generateExportFileName(string $path, array $languages)
mergeLangFiles(string $langFilePath, array $fullLangFilePaths, bool $collectUntranslated=false, array $filterByCodeList=[])
run(string $path='', bool $runBefore=false)
__construct($name, Main\Engine\Controller $controller, array $config=[])
static replaceLangId(string $path, string $langId)
static tidy(string $path)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
clearProgressParameters()
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
performStep($action, array $params=[])
declareAccomplishment(bool $flag=true)
addError(Main\Error $error)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']