21 public function run($file =
'')
32 $normalized = Main\IO\Path::normalize($file);
33 if ($normalized != $file)
39 if (!Translate\
IO\Path::isLangDir($file,
true) || !Translate\
IO\Path::isPhpFile($file))
50 $request = $this->controller->getRequest();
52 $languagesToUpdate = [];
57 $languagesToUpdateTmp = $request->getPost(
'LANGS');
58 if ($languagesToUpdateTmp !==
null && \is_array($languagesToUpdateTmp) && \count($languagesToUpdateTmp) > 0)
62 unset($languagesToUpdateTmp);
64 $currentEncoding = Main\Localization\Translation::getCurrentEncoding();
69 if (!\in_array($langId, $languagesToUpdate))
74 $langRelPath = Translate\IO\Path::replaceLangId($file, $langId);
75 $fullPath = Translate\IO\Path::tidy(
$documentRoot.
'/'.$langRelPath);
76 $fullPath = Main\Localization\Translation::convertLangPath($fullPath, $langId);
81 ->setOperatingEncoding($currentEncoding);
84 if ($langFile->isExists() && Translate\Config::needToBackUpFiles())
86 if (!$langFile->backup())
89 Loc::getMessage(
'TR_CREATE_BACKUP_ERROR', [
'#FILE#' => $langFile->getPath()])
94 $fileSrcForSave = $request->getPost(
'SRC_'. $langId);
96 if (empty($fileSrcForSave) || !\is_string($fileSrcForSave))
102 if (!$langFile->lint($fileSrcForSave))
104 $this->
addErrors($langFile->getErrors());
110 if (!$langFile->putContents($fileSrcForSave))
112 if ($langFile->hasErrors())
114 $this->
addErrors($langFile->getErrors());
120 if (!$langFile->load() && $langFile->hasErrors())
122 $this->
addErrors($langFile->getErrors());
124 elseif ($langFile->count() > 0)
126 $langFile->updatePhraseIndex();
132 if (!$langFile->isExists())
135 Loc::getMessage(
'TR_ERROR_WRITE_CREATE', [
'#FILE#' => $langFile->getPath()])
141 Loc::getMessage(
'TR_ERROR_WRITE_UPDATE', [
'#FILE#' => $langFile->getPath()])