public function onlineTranslate($lang = array('ru', 'en'), $text)
 {
     $t = new yandexTranslate();
     $response = $t->translate(array($lang[0], $lang[1]), $text);
     header('Content-Type: application/json');
     echo CJSON::encode($response['text']);
 }
    public function createFileLanguage($fullpath, $filename, $langs = array(), $content = array())
    {
        $newLangPath = $fullpath . DS . $langs[1];
        if (!is_dir($newLangPath)) {
            mkdir($newLangPath, 0750);
        }
        $t = new yandexTranslate();
        $fh = fopen($newLangPath . DS . $filename, "w");
        if (!is_resource($fh)) {
            return false;
        }
        fclose($fh);
        $params = array();
        $result = array();
        $spec = array();
        $num = -1;
        foreach ($content as $key => $val) {
            $params[] = $val;
            $num++;
            $spec[$num] = $key;
        }
        $response = $t->translate($langs, $params);
        foreach ($response['text'] as $k => $v) {
            $result[$spec[$k]] = $v;
        }
        if (!@file_put_contents($newLangPath . DS . $filename, '<?php

/**
 * Message translations. (auto translate)
 * 
 * Each array element represents the translation (value) of a message (key).
 * If the value is empty, the message is considered as not translated.
 * Messages that no longer need translation will have their translations
 * enclosed between a pair of \'@@\' marks.
 * 
 * @author Andrew (Panix) Semenov <*****@*****.**>
 * @package modules.messages.' . $langs[1] . '
 */
return ' . var_export($result, true) . ';')) {
            throw new CException(Yii::t('admin', 'Error write modules setting in {file}...', array('{file}' => $filename)));
        }
        // return true;
    }