Создание сайтов на 1С-Битрикс

Бесплатный перевод php api translate

<?
function getTranslate($text, $toLang = 'en') {
    $get = array(
        'sl' => 'ru',
        'dl' => $toLang,
        'text'  => trim($text),
    );
    if(is_callable('curl_init')) {
        $ch = curl_init('https://ftapi.pythonanywhere.com/translate?' . http_build_query($get));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
        $html = curl_exec($ch);
        curl_close($ch);
        
        $return = json_decode($html, true);
        if($return['destination-text']) {
            return trim($return['destination-text']);
        } else {
            return false;
        }
    } else {
        return false;
    }
}


Логотип SiteBERG
Изменено: 01.11.2025 12:50

Источник: https://ftapi.pythonanywhere.com

Статьи

Что нужно сделать?