Admin_KeyValueController::translateAction PHP Метод

translateAction() публичный Метод

public translateAction ( )
    public function translateAction()
    {
        $success = false;
        $keyId = $this->getParam("keyId");
        $objectId = $this->getParam("objectId");
        $recordId = $this->getParam("recordId");
        $text = $this->getParam("text");
        $translatedValue = $text;
        try {
            $keyConfig = KeyValue\KeyConfig::getById($keyId);
            $translatorID = $keyConfig->getTranslator();
            $translatorConfig = KeyValue\TranslatorConfig::getById($translatorID);
            $className = $translatorConfig->getTranslator();
            if (\Pimcore\Tool::classExists($className)) {
                $translator = new $className();
                $translatedValue = $translator->translate($text);
                if (!$translatedValue) {
                    $translatedValue = $text;
                }
            }
            $this->_helper->json(["success" => true, "keyId" => $this->getParam("keyId"), "text" => $text, "translated" => $translatedValue, "recordId" => $recordId]);
        } catch (\Exception $e) {
        }
        $this->_helper->json(["success" => $success]);
    }