當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Translation類代碼示例

本文整理匯總了PHP中Translation的典型用法代碼示例。如果您正苦於以下問題:PHP Translation類的具體用法?PHP Translation怎麽用?PHP Translation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Translation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run_create_translation

function run_create_translation($args, $opts)
{
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    $opts = $filter->xssFilterHard($opts);
    $args = $filter->xssFilterHard($args);
    $rootDir = realpath(__DIR__."/../../../../");
    $app = new Maveriks\WebApplication();
    $app->setRootDir($rootDir);
    $loadConstants = false;

    $workspaces = get_workspaces_from_args($args);
    $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';

    $translation = new Translation();
    CLI::logging("Updating labels Mafe ...\n");
    foreach ($workspaces as $workspace) {
        try {
            echo "Updating labels for workspace " . pakeColor::colorize($workspace->name, "INFO") . "\n";
            $translation->generateTransaltionMafe($lang);
        } catch (Exception $e) {
            echo "Errors upgrading labels for workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n";
        }
    }

    CLI::logging("Create successful\n");

}
開發者ID:hpx2206,項目名稱:processmaker-1,代碼行數:28,代碼來源:cliMafe.php

示例2: storeTranslation

 public function storeTranslation($data, $locale = null, $options = [])
 {
     if (!$locale) {
         $locale = config('app.locale');
     }
     $translation = new Translation();
     return $translation->store($this, $locale, $data, $options);
 }
開發者ID:escapework,項目名稱:laravel-translations,代碼行數:8,代碼來源:Translatable.php

示例3: translate

 public static function translate($key_phrase)
 {
     $tTable = new Translation();
     $select = $tTable->select()->where("key_phrase = '{$key_phrase}'");
     $db_phrase = $tTable->fetchRow($select)->phrase;
     if (ITechTranslate::getLocale() == 'en_EN.UTF-8') {
         return $db_phrase;
     } else {
         return t($db_phrase);
     }
 }
開發者ID:falafflepotatoe,項目名稱:trainsmart-code,代碼行數:11,代碼來源:Translation.php

示例4: run

 public function run()
 {
     if (Yii::app()->request->getPost('translate')) {
         //переклади в таблиці translation
         $model = new Translation();
         $model->object = Yii::app()->request->getPost('table');
         $row = Yii::app()->request->getPost('translate');
         $subject = Yii::app()->request->getPost('column');
         $exist = $model->findByPk(Yii::app()->request->getPost('tr_id'));
         if ($exist) {
             $compare = $model->findByAttributes(array('translate' => $row));
             if ($compare) {
                 echo CJSON::encode(array('status' => 'error'));
                 Yii::app()->end();
             }
             $model = $exist;
         }
         $model->subject = $subject;
         $model->row_id = Yii::app()->request->getPost('row_id');
         $model->lan_id = Yii::app()->request->getPost('lan_id');
         $model->translate = Yii::app()->request->getPost('translate');
         if ($lastId = $model->Add()) {
             echo CJSON::encode(array('status' => 'success', 'tr_id' => $lastId));
             Yii::app()->end();
         }
     } else {
         //перекладаєм оригінальний текст
         $table = ucfirst(Yii::app()->request->getPost('table'));
         $object = new $table();
         $subject = Yii::app()->request->getPost('column');
         $row = Yii::app()->request->getPost('row');
         $row_id = Yii::app()->request->getPost('row_id');
         $object->setAttribute($subject, $row);
         $exist = $object->findByPk($row_id);
         if ($exist) {
             $compare = $object->findByAttributes(array($subject => $row));
             if ($compare) {
                 echo CJSON::encode(array('status' => 'error'));
                 Yii::app()->end();
             }
             $object = $exist;
         } else {
             echo CJSON::encode(array('status' => 'error'));
         }
         $object->{$subject} = Yii::app()->request->getPost('row');
         if ($object->Add()) {
             echo CJSON::encode(array('status' => 'success'));
             Yii::app()->end();
         }
     }
     echo CJSON::encode(array('status' => 'error'));
     Yii::app()->end();
 }
開發者ID:vasia-ostapchuk,項目名稱:source,代碼行數:53,代碼來源:TranslateAction.php

示例5: testConstruct

 public function testConstruct()
 {
     try {
         $dataObject = new Translation(array('invalid' => 'foo'));
         $this->fail('Expected \\UnexpectedValueException exception not thrown.');
     } catch (\UnexpectedValueException $e) {
     }
     $dataObject = new Translation(array('translatedText' => 'foo'));
     $this->assertEquals($dataObject->getTranslatedText(), 'foo');
     $this->assertNull($dataObject->getDetectedSourceLanguage());
     $dataObject = new Translation(array('translatedText' => 'foo', 'detectedSourceLanguage' => 'bar'));
     $this->assertEquals($dataObject->getTranslatedText(), 'foo');
     $this->assertEquals($dataObject->getDetectedSourceLanguage(), 'bar');
 }
開發者ID:jiangxilong,項目名稱:google-apis-php-clients,代碼行數:14,代碼來源:TranslationTest.php

示例6: get_Schedule

 function get_Schedule($id, $ident)
 {
     global $globalDebug;
     // Get schedule here, so it's done only one time
     $Connection = new Connection();
     $dbc = $Connection->db;
     $Spotter = new Spotter($dbc);
     $Schedule = new Schedule($dbc);
     $Translation = new Translation($dbc);
     $operator = $Spotter->getOperator($ident);
     if ($Schedule->checkSchedule($operator) == 0) {
         $operator = $Translation->checkTranslation($ident);
         if ($Schedule->checkSchedule($operator) == 0) {
             $schedule = $Schedule->fetchSchedule($operator);
             if (count($schedule) > 0) {
                 if ($globalDebug) {
                     echo "-> Schedule info for " . $operator . " (" . $ident . ")\n";
                 }
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
                 // FIXME : Check if route schedule = route from DB
                 if ($schedule['DepartureAirportIATA'] != '') {
                     if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
                         $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
                         if ($airport_icao != '') {
                             $this->all_flights[$id]['departure_airport'] = $airport_icao;
                             if ($globalDebug) {
                                 echo "-> Change departure airport to " . $airport_icao . " for " . $ident . "\n";
                             }
                         }
                     }
                 }
                 if ($schedule['ArrivalAirportIATA'] != '') {
                     if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
                         $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
                         if ($airport_icao != '') {
                             $this->all_flights[$id]['arrival_airport'] = $airport_icao;
                             if ($globalDebug) {
                                 echo "-> Change arrival airport to " . $airport_icao . " for " . $ident . "\n";
                             }
                         }
                     }
                 }
                 $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
             }
         }
     }
     //$Connection->db = null;
 }
開發者ID:sysrun,項目名稱:FlightAirMap,代碼行數:49,代碼來源:class.SpotterImport.php

示例7: __construct

 public function __construct($door = "")
 {
     //iniciando a config básico, a menos que exita outro config, este vai ser o que vai ficar valendo
     $domain = Navigation::getURIDomain();
     if ($door) {
         //use em $door ":8080" por exemplo
         $domain = str_replace($door, "", $domain);
     }
     include "configs/" . $domain . "/config.php";
     //se não foi passado algum locale na url apos o nome do site faz um redirect passando o locale padrão
     $folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
     $locale = Config::getLocale();
     Translation::setLocale($locale);
     //inicia e pega resultado da controller
     $this->HttpResult = $this->getControllerResult();
     //agora verifica que tipo de retorno esperado e chama a view, se for o caso
     $ignore_name = Config::getAliasFolder();
     if (Config::getLocale()) {
         $ignore_name .= "/" . Config::getLocale();
     }
     //url com trata com regras de rota
     $url = explode("/", Config::rewriteUrl(Navigation::getURI($ignore_name, Navigation::URI_RETURN_TYPE_STRING)));
     $retornoDaView = self::searchFile($url, Config::getFolderView());
     if ($retornoDaView->success) {
         //echo Debug::li("retornoDaView:".$retornoDaView->urlToInclude);
         $this->view = $retornoDaView->urlToInclude;
     } else {
         $this->view = Config::getFolderView() . "/index.php";
     }
 }
開發者ID:reytuty,項目名稱:facil,代碼行數:30,代碼來源:HttpRequestController.php

示例8: initialize

 public function initialize($session, $force = false)
 {
     if (!$session->has('translateEngine') || $session->get('translateEngine') == null || $force) {
         $this->translations = \Translation::find("INSTR(lang,'" . $this->language . "')>0");
         $session->set('translateEngine', $this);
     }
 }
開發者ID:jcheron,項目名稱:phalcon-jquery-website,代碼行數:7,代碼來源:TranslateEngine.php

示例9: smarty_block_translation

/**
 * Translate a string
 */
function smarty_block_translation($params, $content, $smarty, &$repeat)
{
    return $content;
    if ($content !== null) {
        return Translation::translate($content, $smarty->tpl_vars['env']->value['translation']);
    }
}
開發者ID:tigron,項目名稱:skeleton-template-smarty,代碼行數:10,代碼來源:smarty_extensions.php

示例10: __construct

 public function __construct()
 {
     //iniciando a config básico, a menos que exita outro config, este vai ser o que vai ficar valendo
     include "configs/" . str_replace(":8888", "", Navigation::getURIDomain()) . "/config.php";
     //se não foi passado algum locale na url apos o nome do site faz um redirect passando o locale padrão
     //echo Debug::li(Config::getAliasFolder());
     $folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
     //echo Debug::li(Config::getRootApplication());
     //$folders_array = Navigation::getURI(Config::getAliasFolder(), Navigation::URI_RETURN_TYPE_ARRAY);
     $locale = Config::getLocale();
     Translation::setLocale($locale);
     //inicia e pega resultado da controller
     $this->HttpResult = $this->getControllerResult();
     //agora verifica que tipo de retorno esperado e chama a view, se for o caso
     $ignore_name = Config::getAliasFolder();
     if (Config::getLocale()) {
         $ignore_name .= "/" . Config::getLocale();
     }
     //url com trata com regras de rota
     $url = explode("/", Config::rewriteUrl(Navigation::getURI($ignore_name, Navigation::URI_RETURN_TYPE_STRING)));
     $retornoDaView = self::searchFile($url, Config::getFolderView());
     //Navigation::searchFileOrFolder(Config::getRootApplication()."/".Config::getLocale(), Config::getFolderView(), Navigation::SEARCH_FILE_MODE_FILE);
     //echo Debug::li("retornoDaView");
     //Debug::print_r($retornoDaView);
     if ($retornoDaView->success) {
         //echo Debug::li("retornoDaView:".$retornoDaView->urlToInclude);
         $this->view = $retornoDaView->urlToInclude;
     } else {
         $this->view = Config::getFolderView() . "/index.php";
     }
     //exit();
     //Debug::print_r("[SEARCH_FILE_MODE_CLASS_AND_METHOD]:".Navigation::searchFileOrFolder(Config::FOLDER_ROOT_APPLICATION, "view/democrart/", Navigation::SEARCH_FILE_MODE_CLASS_AND_METHOD, "", TRUE));
 }
開發者ID:reytuty,項目名稱:facil,代碼行數:33,代碼來源:HttpRequestController.php

示例11: showLangModal

 public function showLangModal()
 {
     $language = Yii::app()->params['language'];
     $this->beginWidget('bootstrap.widgets.TbModal', array('id' => $this->modalId, 'htmlOptions' => array('style' => 'margin-top:-200px;', 'backdrop' => 'static')));
     echo "<div class=\"modal-header\">\n                <h4 style=\"width:30%;display: inline-block;\">翻譯</h4> \n                <span id='" . $this->modalId . "message' style=\"margin-left:30px;color:red;\"></span>\n            </div>";
     echo "<div id='" . $this->modalId . "ModalBody' class=\"modal-body\" style=\"text-align:center\">";
     $tableName = $this->model->tableName();
     $attribute = $this->attribute;
     echo CHtml::hiddenField('tableName', $tableName);
     echo CHtml::hiddenField('attribute', $attribute);
     $pk = $this->model->primaryKey;
     echo CHtml::activeHiddenField($this->model, $this->model->pk, array('name' => 'pk'));
     $result = Translation::model()->find('model=:tableName and pk=:pk and attribute=:attribute', array(':tableName' => $tableName, ':pk' => $pk, ':attribute' => $attribute));
     $data = json_decode($result->data);
     foreach ($language as $key => $value) {
         if (strtolower($key) == 'zh_cn') {
             continue;
         }
         echo "<div><span style='width:80px !important;display: inline-block;'>" . $value . '</span>' . CHtml::textField($key, $data->{$key}) . "</div>";
     }
     echo "</div>";
     echo "<div class=\"modal-footer\" style=\"text-align: center;\">";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'info', 'label' => '保存', 'htmlOptions' => array('id' => $this->modalId . 'save')));
     echo "&nbsp;";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'label' => '取消', 'htmlOptions' => array("data-dismiss" => "modal", 'id' => $this->modalId . 'back')));
     echo "</div>";
     $this->endWidget();
 }
開發者ID:GsHatRed,項目名稱:Yiitest,代碼行數:28,代碼來源:TTranslate.php

示例12: __construct

 public function __construct()
 {
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
     } else {
         $lang = "en";
     }
     switch ($lang) {
         case "de":
             include PATH . "inc/language_de.php";
             Translation::$languageDict = $_;
             unset($_);
             break;
         case "en":
             include PATH . "inc/language_en.php";
             Translation::$languageDict = $_;
             unset($_);
             break;
         default:
             include PATH . "inc/language_en.php";
             Translation::$languageDict = $_;
             unset($_);
             break;
     }
 }
開發者ID:iekadou,項目名稱:lightpainting,代碼行數:25,代碼來源:Translation.php

示例13: _n

/**
 * Retrieve the singular or plural translation of the string.
 *
 * @since 2.2
 *
 * @param string $single_key
 * @param string $plural_key
 * @param int $count
 * @param string $domain
 * @return string
 */
function _n($single_key, $plural_key, $count, $domain = 'core')
{
    $gt = Translation::newInstance()->_get($domain);
    if (!$gt) {
        return $key;
    }
    return $gt->ngettext($single_key, $plural_key, $count);
}
開發者ID:acharei,項目名稱:OSClass,代碼行數:19,代碼來源:hTranslations.php

示例14: __construct

 public function __construct()
 {
     parent::__construct();
     $this->http_header->setTitle(Translation::text("A maior galeria de arte do Brasil em edição limitada, numerada e assinada de quadros, gravuras e fotografias. Decore com arte."));
     $this->http_header->setDescription(Translation::text("A maior galeria de arte do Brasil em edição limitada, numerada e assinada de quadros, gravuras e fotografias. Decore com arte."));
     $this->http_header->getKeywords(Translation::text("quadros gravuras,quadros online,venda quadros,desenhos,venda de quadros,reproduções,artes,comprar gravuras,comprar quadros,gravura,gravuras,loja quadros,quadros,decoração de interiores quartos,decoração de ambientes interiores,decoração de interiores salas,arte moderna,quadros decorativos,papel de parede decoração de interiores,dicas de decoração para quartos,papel de parede para quarto de bebe,papel de parede decoração quarto,lojas decoração interiores,decoração de paredes interiores,revista de decoração de interiores,fotos decoração de sala,dicas de decoração de interiores,decoração design de interiores,pintura em tela a oleo,pintura em tela,objetos de decoração para sala,quadros de parede,quarto de bebe,gravuras para quadros,adesivos decorativos de parede,papel de parede,papel de parede para quarto,quartos de bebe decorados,galerias de arte sp,molduras para quadros,sites de decoração de interiores,galeria de arte virtual,galerias de arte rio de janeiro,ideias decoração interiores,site de decoração de casas,adesivos de parede,decoração de interiores cozinha,decoração de quarto infantil menina,quadros em mdf,adesivos decoração interiores,quadros abstratos modernos,quadros pintura abstrata,decoração parede quarto,quadros para quarto de bebe,decoração interiores sala estar,decoração pintura parede,quadros pintura em tela,decoração festa junina infantil,adesivos de parede infantil,papel de parede para quarto infantil,quadros para quarto de casal,quarto de menina,galeria arte quadros,pintura quarto de bebe,quadro de fotos,papel de parede infantil,moveis para quarto de bebe,decoração de interiores banheiros,objetos de decoração de interiores,decoração de quarto de bebe com papel de parede,fotos de decoração de cozinha,adesivos de parede para quarto de bebe,\r\ndecoração de ambientes casa,cortinas para quarto de bebe,quadro de avisos,loja de quadros,decoração cozinhas planejadas,dicas de decoração de sala,decoração textura parede,decoração parede sala,quartos decorados,site de decoração de quartos,objetos de decoração para quarto,decoração de interiores de apartamentos,pintura em tela abstrato,quadros pintados,cozinha americana decoração,rei dos quadros,adesivos de parede tok stok,quarto de bebe menina,moveis e decoração de casas,adesivos decorativos,pintura de parede,quarto infantil,festa infantil,fotos de decoração de banheiros,papel de parede decorativo,quadros para decoração de sala,quadros decorativos para sala"));
     $this->arrayProducts = array();
 }
開發者ID:reytuty,項目名稱:facil,代碼行數:8,代碼來源:HttpClientRegister.class.php

示例15: _n

/**
 * Retrieve the singular or plural translation of the string.
 *
 * @since 2.2
 *
 * @param string $single_key
 * @param string $plural_key
 * @param int $count
 * @param string $domain
 * @return string
 */
function _n($single_key, $plural_key, $count, $domain = 'core')
{
    $gt = Translation::newInstance()->_get($domain);
    if (!$gt) {
        return $key;
    }
    $string = $gt->ngettext($single_key, $plural_key, $count);
    return osc_apply_filter('ngettext', $string);
}
開發者ID:semul,項目名稱:Osclass,代碼行數:20,代碼來源:hTranslations.php


注:本文中的Translation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。