- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/controller/asset/apply.php
- Класс: BitrixTranslateControllerAssetApply
- Вызов: Apply::run
public function run()
{
// continue previous process
$progressParams = $this->getProgressParameters();
$this->languageId = $progressParams['languageId'];
$this->tmpFolderPath = $progressParams['tmpFolderPath'];
$this->totalFileCount = $progressParams['totalFileCount'];
if ($this->isNewProcess)
{
$this->totalItems = $this->totalFileCount;
$this->processedItems = 0;
// language
$languageId = $this->controller->getRequest()->get('languageId');
if (empty($languageId))
{
$this->addError(new MainError(Loc::getMessage('TR_ERROR_SELECT_LANGUAGE')));
}
if (!in_array($languageId, self::$enabledLanguages))
{
$this->addError(new MainError(Loc::getMessage('TR_ERROR_LANGUAGE_ID')));
}
else
{
$this->languageId = $languageId;
}
// convert encoding
$this->convertEncoding = ($this->controller->getRequest()->get('localizeEncoding') === 'Y');
// encoding
$encoding = $this->controller->getRequest()->get('encoding');
if ($encoding !== null && in_array($encoding, self::$allowedEncodings))
{
$this->encoding = $encoding;
}
elseif ($this->convertEncoding)
{
$this->addError(new MainError(Loc::getMessage('TR_ERROR_ENCODING')));
}
if ($this->convertEncoding)
{
if (self::$useTranslationRepository)
{
$encodingIn = $this->encoding;
$encodingOut = MainLocalizationTranslation::getSourceEncoding($this->languageId);
}
elseif (TranslateConfig::isUtfMode())
{
$encodingIn = $this->encoding;
$encodingOut = 'utf-8';
}
else
{
$encodingIn = 'utf-8';
$encodingOut = TranslateConfig::getCultureEncoding($this->languageId);
if (!$encodingOut)
{
$encodingOut = MainLocalizationTranslation::getCurrentEncoding();
}
}
$this->convertEncoding = (mb_strtolower($encodingIn) !== mb_strtolower($encodingOut));
$this->encodingIn = $encodingIn;
$this->encodingOut = $encodingOut;
}
$this->sourceFolderPath = TranslateIOPath::tidy($this->tmpFolderPath .'/'. $this->languageId. '/');
$sourceDirectory = new TranslateIODirectory($this->sourceFolderPath);
if (!$sourceDirectory->isExists())
{
$this->addError(
new Error(Loc::getMessage('TR_ERROR_CREATE_TARGET_FOLDER', ['#PATH#' => $this->sourceFolderPath]))
);
}
if (
self::$useTranslationRepository &&
MainLocalizationTranslation::isDefaultTranslationLang($this->languageId) !== true
)
{
$this->targetFolderPath = TranslateIOPath::tidy(self::$translationRepositoryRoot. '/'. $this->languageId.'/');
$targetFolder = new TranslateIODirectory($this->targetFolderPath);
if (!$targetFolder->isExists())
{
$targetFolder->create();
}
}
else
{
$this->targetFolderPath = MainApplication::getDocumentRoot().'/bitrix/modules/';
}
$this->saveProgressParameters();
return [
'STATUS' => ($this->totalItems > 0 ? TranslateControllerSTATUS_PROGRESS : TranslateControllerSTATUS_COMPLETED),
'PROCESSED_ITEMS' => 0,
'TOTAL_ITEMS' => $this->totalItems,
];
}
$this->targetFolderPath = $progressParams['targetFolderPath'];
$this->convertEncoding = $progressParams['convertEncoding'];
$this->encodingIn = $progressParams['encodingIn'];
$this->encodingOut = $progressParams['encodingOut'];
$this->seekPath = $progressParams['seekPath'];
return $this->performStep('runApplying');
}