当前位置: 首页>>代码示例>>PHP>>正文


PHP Translate::translate方法代码示例

本文整理汇总了PHP中Translate::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::translate方法的具体用法?PHP Translate::translate怎么用?PHP Translate::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translate的用法示例。


在下文中一共展示了Translate::translate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAssign

 /**
  * @covers \Translate\Translator::assign()
  * @covers \Translate\Translator::translate()
  * @covers \Translate\Translator::setDefault()
  */
 public function testAssign()
 {
     // 1. check method exist
     $this->assertTrue(method_exists($this->translate, 'assign'), '[-] Class Translate must have method assign()');
     // 2. check method modifier
     $modifiers = (new \ReflectionMethod(self::TEST_CLASS, 'assign'))->getModifiers();
     $this->assertEquals(['public'], \Reflection::getModifierNames($modifiers), "[-] assign() method must be as public");
     // 1. check method exist
     $this->assertTrue(method_exists($this->translate, 'translate'), '[-] Class Translate must have method translate()');
     // 2. check method modifier
     $modifiers = (new \ReflectionMethod(self::TEST_CLASS, 'translate'))->getModifiers();
     $this->assertEquals(['public'], \Reflection::getModifierNames($modifiers), "[-] translate() method must be as public");
     $assign = $this->translate->setTranslatePath(self::TEST_PATH)->setLanguage(self::TEST_LANG)->assign(self::TEST_PART)->setDefault('ru');
     // 3. check instance of method
     $this->assertInstanceOf($this->reflection->getName(), $assign, "[-] assign() method must be as instance of " . self::TEST_CLASS);
     // 4. check RIGHT and WRONG returns
     $translate = $assign->translate('HOME');
     $this->assertInternalType('string', $translate, "[-] translate() must return type as string if has right");
     $translate = $assign->translate('WRONG');
     $this->assertInternalType('string', $translate, "[-] translate() must return type as string if has wrong");
     // 5. check exception
     try {
         // get default property value
         $reflectionProperty = $this->reflection->getProperty('signature');
         $reflectionProperty->setAccessible(true);
         $this->signature = $reflectionProperty->setValue($this->translate, []);
         $this->translate->translate('CallException');
     } catch (\Phalcon\Exception $e) {
         // Expected exception caught! Woohoo! Ignore it
         $this->assertInstanceOf('Phalcon\\Exception', $e, "[-] Exception must return Phalcon\\Exception instance");
     }
 }
开发者ID:TheCodemasterZz,项目名称:phalcon-translate,代码行数:37,代码来源:TranslatorTest.php

示例2: addPanel

 /**
  *
  * Add new panel to customizer
  *
  * @throws \SilverWp\Customizer\Panel\Exception
  * @access private
  */
 private function addPanel()
 {
     if (!isset($this->panel_id)) {
         throw new Exception(Translate::translate('If You want add panel to your section first define panel_id class property.'));
     }
     $params = $this->createPanelParams();
     \Kirki::add_panel($this->panel_id, $params);
 }
开发者ID:silversite,项目名称:silverwp,代码行数:15,代码来源:PanelAbstract.php

示例3: __construct

 /**
  * Class constructor
  *
  * @throws \SilverWp\ShortCode\Exception
  */
 public function __construct()
 {
     if (!isset($this->tag_base) && empty($this->tag_base)) {
         throw new Exception(Translate::translate('Class variable $tag_base is required and can\'t be empty.'));
     }
     if (isset($this->remove_attribute) && count($this->remove_attribute)) {
         $this->removeAttribute($this->remove_attribute);
     }
     if (method_exists($this, 'create')) {
         $this->addAttributes();
     }
 }
开发者ID:silversite,项目名称:silverwp,代码行数:17,代码来源:ShortCodeUpdateAbstract.php

示例4: __construct

 /**
  *
  * Class constructor
  *
  * @param string $name
  *
  * @access public
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setRepeating(true);
     $this->setSortable(true);
     $this->setLabel(Translate::translate('Gallery'));
     $name = new Text('name');
     $name->setLabel(Translate::translate('Name'));
     $this->addControl($name);
     $values = new Textarea('values');
     $values->setLabel(Translate::translate('Description'));
     $this->addControl($values);
 }
开发者ID:silversite,项目名称:silverwp,代码行数:21,代码来源:Features.php

示例5: Translate

<?php

require_once "include/include.php";
$word = "Тестовое задание";
try {
    $translate = new Translate();
    $eng = $translate->translate($word);
    echo array_pop($eng['text']) . PHP_EOL;
} catch (Exception $e) {
    echo "ERROR #" . $e->getCode() . ": [" . $e->getMessage() . "]" . PHP_EOL;
}
开发者ID:xxxcoltxxx,项目名称:test,代码行数:11,代码来源:translate.php

示例6: test

 function test()
 {
     $translator = new Translate();
     $translator->setLangFrom('en')->setLangTo('es');
     echo $translator->translate('hello');
     $lang_data = array('sign_in' => 'Sign In', 'sign_up' => 'Sign Up');
     $lang_data_array = $lang_data;
     $translate_array = $translator->get_translated_data_array('en', 'ar', $lang_data_array);
     echo '<pre>';
     print_r($translate_array);
     die;
 }
开发者ID:GiovanniV,项目名称:Santa-Barbara-Business-Directory,代码行数:12,代码来源:system_core.php

示例7: getEditColumns

 /**
  *
  * get list of edit columns displayed in lists of Post Type
  *
  *
  * list of columns displayed in dashboard list. Example
  * array(
  *       'cb' => array(
  *           'html' => '<input type="checkbox" />',
  *       ),
  *       'title' => array(
  *           'label' => 'Title',
  *       ),
  *       'category' => array(
  *            'label' => 'Categories',
  *       ),
  *       'thumbnail' => array(
  *           'label' => 'Thumbnail',
  *       ),
  *       'tag' => array(
  *           'label' => 'Tags',
  *      ),
  *      'date' => array(
  *          'label' => 'Date',
  *      ),
  *      'author' => array(
  *          'label' => 'Author',
  *      ),
  *  );
  *
  * @access protected
  * @return array
  */
 protected function getEditColumns()
 {
     $columns_default = array('cb' => array('html' => '<input type="checkbox" />'), 'title' => array('label' => Translate::translate('Title')), 'thumbnail' => array('label' => Translate::translate('Thumbnail')), 'author' => array('label' => Translate::translate('Author')), 'date' => array('label' => Translate::translate('Date')), 'category' => array('label' => Translate::translate('Categories')), 'tag' => array('label' => Translate::translate('Tags')));
     foreach ($this->columns as $name => $label) {
         $columns_default[$name]['label'] = $label;
     }
     $columns = UtlArray::array_remove_part($columns_default, $this->exclude_columns);
     return $columns;
 }
开发者ID:silversite,项目名称:silverwp,代码行数:42,代码来源:CustomColumns.php

示例8: registerStylesheetsTemplates

 /**
  *
  * Parse and register less file and convert it to css
  *
  * @param string $handler
  * @param string $src      css file source
  * @param array  $deps
  * @param bool   $version
  * @param string $media
  * @param bool   $compress the file should by compressed
  *
  * @return mixed
  * @throws Exception
  * @access public
  */
 public function registerStylesheetsTemplates($handler = 'custom.less', $src = '', array $deps = array(), $version = false, $media = 'all', $compress = false)
 {
     if (class_exists('\\WPLessPlugin')) {
         $less = \WPLessPlugin::getInstance();
         $less->dispatch();
         // we’re done, everything works as if the plugin is activated
         $less_config = $less->getConfiguration();
         $less_config->setUploadDir($this->upload_dir);
         $less_config->setUploadUrl($this->upload_url);
         $css_uri = FileSystem::getDirectory('css_uri');
         $less->setImportDir(array($css_uri . 'less'));
         $less_variable = $this->variables;
         $less->setVariables($less_variable);
         \Less_Parser::$default_options['compress'] = $compress;
         //\Less_Parser::$default_options['cache_method'] = 'serialize';
         \WPLessStylesheet::$upload_dir = $less_config->getUploadDir();
         \WPLessStylesheet::$upload_uri = $less_config->getUploadUrl();
         if (!wp_style_is($handler, 'registered')) {
             if (!$src) {
                 $src = $css_uri . 'less/style.less';
             }
             wp_register_style($handler, $src, $deps, $version, $media);
             wp_enqueue_style($handler);
         }
         return $less->processStylesheet($handler, true);
     } else {
         throw new Exception(Translate::translate('WP-Less plugin not found.'));
     }
 }
开发者ID:silversite,项目名称:silverwp,代码行数:44,代码来源:Less.php


注:本文中的Translate::translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。