• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Translator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderContent

 protected function renderContent($api, $unit, $moduleInfo)
 {
     $items = array();
     // get breadcrumb trail
     if ($api->isPage()) {
         $startPageId = $api->getFormValue($unit, 'navStart');
         // get all page ids in current navigator
         $nav = $api->getNavigation();
         $pageIds = $nav->getNavigatorIds($nav->getCurrentPageId());
         // only show until start page if set
         if (!empty($startPageId) && in_array($startPageId, $pageIds)) {
             $pageIds = array_slice($pageIds, array_search($startPageId, $pageIds) + 1);
         }
         if (is_array($pageIds)) {
             foreach ($pageIds as $pageId) {
                 $page = $nav->getPage($pageId);
                 // echo "\nPAGE: {$page->getTitle()} {$page->getUrl()}";
                 $items[] = array('href' => $api->isEditMode() ? 'javascript:void(0)' : $page->getUrl(), 'title' => $page->getNavigationTitle());
             }
         }
     } else {
         if ($api->isEditMode() || $api->isPreviewMode()) {
             // demo nav items in preview and edit mode
             $i18n = new Translator($api, $moduleInfo);
             $items = array(array('href' => 'javascript:void(0)', 'title' => $i18n->translate('testdata.page') . ' 1'), array('href' => 'javascript:void(0)', 'title' => $i18n->translate('testdata.page') . ' 2'), array('href' => 'javascript:void(0)', 'title' => $i18n->translate('testdata.page') . ' 3'));
         }
     }
     $spacerTag = $this->getBreadcrumbSpacerTag($api->getFormValue($unit, 'spacer'));
     $trail = array();
     foreach ($items as $page) {
         $trail[] = $this->getBreadcrumbItemTag($page)->toString();
     }
     echo implode($spacerTag->toString(), $trail);
     $api->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:35,代码来源:rz_breadcrumb.php


示例2: htmlHeadUnit

 public function htmlHeadUnit($api, $unit, $moduleInfo)
 {
     // enable event only if this extension unit is a direct child of default unit
     $parentUnit = $api->getParentUnit($unit);
     if (!$api->getModuleInfo($parentUnit)->isExtension()) {
         $eventType = $api->getFormValue($unit, 'eventType');
         $eventLimit = $api->getFormValue($unit, 'eventLimit');
         $eventMode = $api->getFormValue($unit, 'eventMode');
         $stateName = '';
         if ($api->getFormValue($unit, 'enableState')) {
             $stateName = $api->getFormValue($unit, 'stateName');
         }
         $selector = substr($api->getFormValue($unit, 'additionalSelector'), 2);
         $code = "window.rz_trigger_event.push({ ";
         $code .= "\"selector\": \"" . $selector . "\", \"parentUnitId\": \"" . $parentUnit->getId() . "\", \"eventType\": \"" . $eventType . "\", \"stateName\": \"" . $stateName . "\", \"eventLimit\": \"" . $eventLimit . "\", \"eventMode\": \"" . $eventMode . "\"";
         if ($eventType == 'scroll') {
             $code .= ",\"scrollConfig\": \"" . $api->getFormValue($unit, 'scrollConfig') . "\"";
         }
         $code .= "});";
         return "<script>" . $code . "</script>";
     } else {
         if ($api->isEditMode()) {
             $i18n = new Translator($api, $moduleInfo);
             $msg = $i18n->translate('error.insideExtensionModule');
             $code = 'alert("' . addslashes($msg) . '");';
         }
         return "<script>" . $code . "</script>";
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:29,代码来源:rz_trigger_event.php


示例3: renderContent

 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     // find all children modules
     $allItems = $renderApi->getChildren($unit);
     $renderItems = array();
     // normal units
     $nonRenderItems = array();
     // extension units
     foreach ($allItems as $item) {
         if ($renderApi->getModuleInfo($item)->isExtension()) {
             // assume that extension modules (i.e. styles) render no html output
             $nonRenderItems[] = $item;
         } else {
             $renderItems[] = $item;
         }
     }
     // wrap all children
     if (empty($renderItems)) {
         if ($renderApi->isEditMode() && $renderApi->isTemplate()) {
             $i18n = new Translator($renderApi, $moduleInfo);
             $msg = $i18n->translate('msg.emptyInEditMode');
             $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
             echo $errorTag->toString();
         }
     } else {
         $wrapTag = new HtmlTagBuilder('div');
         foreach ($renderItems as $renderItem) {
             echo $wrapTag->getOpenString();
             $renderApi->renderUnit($renderItem);
             echo $wrapTag->getCloseString();
         }
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:33,代码来源:rz_ghost_container.php


示例4: renderContent

 protected function renderContent($api, $unit, $moduleInfo)
 {
     if ($api->getFormValue($unit, 'imgsrc') != '') {
         if ($api->getFormValue($unit, 'enableImageLink', '') && !$api->isEditMode()) {
             $linkTitle = $api->getFormValue($unit, 'linkTitle');
             $target = "_self";
             if ($api->getFormValue($unit, 'openNewWindow')) {
                 $target = "_blank";
             }
             echo '<a class="imageContainer" href="' . $this->geturl($api, $unit) . '" title="' . $linkTitle . '" target="' . $target . '">';
         } else {
             echo '<div class="imageContainer">';
         }
         echo $this->getResponsiveImageTag($api, $unit, $moduleInfo)->toString();
         if ($api->isEditMode()) {
             $i18n = new Translator($api, $moduleInfo);
             $title = $i18n->translate('button.cropIconTitle');
             echo '<div class="cropIcon" title="' . $title . '"></div>';
         }
         if ($api->getFormValue($unit, 'showCaption', '')) {
             echo '<div class="imageCaption">' . $api->getFormValue($unit, 'imageTitle', '') . '</div>';
         }
         if ($api->getFormValue($unit, 'enableImageLink', '') && !$api->isEditMode()) {
             echo '</a>';
         } else {
             echo '</div>';
         }
     }
     echo $api->getEditableTag($unit, 'text', 'div', 'class="text"');
     $api->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:31,代码来源:rz_text_image.php


示例5: showNoAnchorsHint

 /**
  * @param \Render\APIs\APIv1\RenderAPI  $renderApi
  * @param \Render\Unit                  $unit
  * @param \Render\ModuleInfo            $moduleInfo
  */
 protected function showNoAnchorsHint($renderApi, $unit, $moduleInfo)
 {
     $i18n = new Translator($renderApi, $moduleInfo);
     $msg = $i18n->translate('hint.noAnchor');
     $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
     echo $errorTag->toString();
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:12,代码来源:rz_anchor_navigation.php


示例6: testSerialize

 public function testSerialize()
 {
     $test = array('en' => 'english', 'fr' => 'french');
     $translator = new Translator();
     $translator->processInput($test);
     // test if json serialization is correct
     $this->assertJsonStringEqualsJsonString(json_encode($test), $translator->serialize());
 }
开发者ID:aozisik,项目名称:translatable,代码行数:8,代码来源:TranslatorTest.php


示例7: testTranslateAlphabet

 /**
  * @dataProvider providerTestTranslateAlphabet
  */
 public function testTranslateAlphabet($expected, $letters)
 {
     $translator = new Translator(new Impulsions\DotAndDash());
     $separedtedLetters = preg_split('~~u', $letters, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($separedtedLetters as $letter) {
         $this->assertSame($expected, $translator->morsify($letter));
     }
 }
开发者ID:lebris,项目名称:morse,代码行数:11,代码来源:TranslatorTest.php


示例8: getTranslatorToLocale

 static function getTranslatorToLocale($str = "us")
 {
     if (!isset(self::$trl[$str])) {
         $cfg = self::getConfig();
         $trl = new Translator($cfg);
         $trl->setLanguage($str);
         self::$trl[$str] = $trl;
     }
     return self::$trl[str];
 }
开发者ID:KingsleyGU,项目名称:OSTicket-Reloaded,代码行数:10,代码来源:class.sys.php


示例9: renderContent

 protected function renderContent($api, $unit, $moduleInfo)
 {
     echo $this->getResponsiveImageTag($api, $unit, $moduleInfo)->toString();
     if ($api->isEditMode()) {
         $i18n = new Translator($api, $moduleInfo);
         $title = $i18n->translate('button.cropIconTitle');
         echo '<div class="cropIcon" title="' . $title . '"></div>';
     }
     $api->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:10,代码来源:rz_image.php


示例10: renderContent

 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $responsiveImage = new ResponsiveImageBuilder($renderApi, $unit, $moduleInfo);
     $imageIds = $renderApi->getFormValue($unit, 'sliderImageIds', array());
     $imageQuality = null;
     if ($renderApi->getFormValue($unit, 'enableImageQuality')) {
         $imageQuality = $renderApi->getFormValue($unit, 'imageQuality');
     }
     $globalHeightPercent = str_replace('%', '', $renderApi->getFormValue($unit, 'imgHeight'));
     // render children (non extensions)
     if (count($imageIds) > 0) {
         echo '<ul class="slides">';
         $i = 0;
         foreach ($imageIds as $imageId) {
             // image
             try {
                 $image = $renderApi->getMediaItem($imageId)->getImage();
                 if ($globalHeightPercent == 0) {
                     $heightPercent = $image->getHeight() / $image->getWidth() * 100;
                 } else {
                     $heightPercent = $globalHeightPercent;
                 }
                 $cropHeight = $image->getWidth() * $heightPercent / 100;
                 // slides
                 if ($i == 0) {
                     echo '<li class="slide slideActive">';
                 } else {
                     echo '<li class="slide">';
                 }
                 $i++;
                 // image tag
                 $imgTag = $responsiveImage->getImageTag($image, array('resize' => array('width' => $image->getWidth(), 'height' => $cropHeight), 'quality' => $imageQuality));
                 if (isset($imgTag)) {
                     echo $imgTag->toString();
                 }
                 echo '</li>';
             } catch (\Exception $e) {
             }
         }
         echo '</ul>';
     } else {
         if ($renderApi->isEditMode()) {
             // missing input hint
             $i18n = new Translator($renderApi, $moduleInfo);
             echo '<div class="RUKZUKmissingInputHint">';
             echo '<div>';
             echo '<button onclick="javascript:CMS.openFormPanel(\'sliderImageIds\');">';
             echo $i18n->translate('button.missingInputHint', 'Choose images');
             echo '</button>';
             echo '</div>';
             echo '</div>';
         }
     }
     $renderApi->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:60,代码来源:rz_slider_images.php


示例11: testTranslateMissingKey

 public function testTranslateMissingKey()
 {
     $formatter = $this->getMock(get_class($this->formatter));
     // create fallback translator
     $translator = new Translator('en_US', [], $formatter);
     $formatter->expects($this->once())->method('format')->with('en_US', 'TEXT', ['var' => 'SOME'])->will($this->returnValue('FORMATTED'));
     // key does not exist, with tokens passed
     $expect = 'FORMATTED';
     $actual = $translator->translate('TEXT', ['var' => 'SOME']);
     $this->assertEquals($expect, $actual);
 }
开发者ID:Slayug,项目名称:castor,代码行数:11,代码来源:TranslatorTest.php


示例12: run

 public function run()
 {
     $this->input = filter_input(INPUT_POST, 'english', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     if (isset($this->input)) {
         $lexer = new Lexer($this->input);
         $tokens = $lexer->run();
         $translator = new Translator($tokens);
         $result = $translator->run();
         if ($this->isAjax()) {
             $this->sendPayload($result);
         }
     }
 }
开发者ID:martinsifra,项目名称:PigLatin,代码行数:13,代码来源:Driver.php


示例13: htmlHeadUnit

 public function htmlHeadUnit($api, $unit, $moduleInfo)
 {
     // enable event only if this extension unit is a direct child of default unit
     $parentUnit = $api->getParentUnit($unit);
     if ($api->getModuleInfo($parentUnit)->isExtension()) {
         if ($api->isEditMode()) {
             $i18n = new Translator($api, $moduleInfo);
             $msg = $i18n->translate('error.insideExtensionModule');
             $code = 'alert("' . addslashes($msg) . '");';
         }
         return "<script>" . $code . "</script>";
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:13,代码来源:rz_style_styleset.php


示例14: renderContent

 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit                 $unit
  * @param \Render\ModuleInfo           $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $imageIds = $this->getImageIds($renderApi, $unit);
     $imageQuality = null;
     if ($renderApi->getFormValue($unit, 'enableImageQuality')) {
         $imageQuality = $renderApi->getFormValue($unit, 'imageQuality');
     }
     $globalHeightPercent = str_replace('%', '', $renderApi->getFormValue($unit, 'imgHeight'));
     // render images
     if (count($imageIds) > 0) {
         echo '<ul>';
         foreach ($imageIds as $imageId) {
             try {
                 // image
                 $image = $renderApi->getMediaItem($imageId)->getImage();
                 if ($globalHeightPercent == 0) {
                     $heightPercent = $image->getHeight() / $image->getWidth() * 100;
                 } else {
                     $heightPercent = $globalHeightPercent;
                 }
                 $cropHeight = $image->getWidth() * $heightPercent / 100;
                 if ($renderApi->getFormValue($unit, 'showImageTitles')) {
                     $name = $renderApi->getMediaItem($imageId)->getName();
                     $attributes = array('title' => $name);
                 } else {
                     $attributes = null;
                 }
                 // image tag
                 $imgTag = $this->getResponsiveImage($renderApi, $unit, $moduleInfo)->getImageTag($image, array('resize' => array('width' => $image->getWidth(), 'height' => $cropHeight), 'quality' => $imageQuality), $attributes);
                 echo '<li>' . $imgTag->toString() . '</li>';
             } catch (\Exception $doNothing) {
             }
         }
         echo '</ul>';
     } else {
         if ($renderApi->isEditMode()) {
             // missing input hint
             $i18n = new Translator($renderApi, $moduleInfo);
             echo '<div class="RUKZUKmissingInputHint">';
             echo '<div>';
             echo '<button onclick="javascript:CMS.openFormPanel(\'galleryImageIds\');">';
             echo $i18n->translate('button.missingInputHint', 'Choose images');
             echo '</button>';
             echo '</div>';
             echo '</div>';
         }
     }
     $renderApi->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:54,代码来源:rz_thumbnail_gallery.php


示例15: renderContent

 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $listTag = new HtmlTagBuilder('ul', array('class' => 'isTeaserList'));
     echo $listTag->getOpenString();
     // show hint when no children inserted
     if ($renderApi->isEditMode() && count($renderApi->getChildren($unit)) === 0) {
         $i18n = new Translator($renderApi, $moduleInfo);
         $msg = $i18n->translate('error.pleaseInsertModules');
         $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
         echo $errorTag->toString();
     } else {
         $this->renderTeaserList($renderApi, $unit);
     }
     echo $listTag->getCloseString();
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:15,代码来源:rz_page_list.php


示例16: htmlHeadUnit

 /**
  * @param \Render\APIs\APIv1\CSSAPI $api
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  * @return string
  */
 protected function htmlHeadUnit($api, $unit, $moduleInfo)
 {
     $parentUnit = $api->getParentUnit($unit);
     // enable animation only if this extension unit is a direct child of default unit
     if (!$api->getModuleInfo($parentUnit)->isExtension()) {
         $selector = '#' . $parentUnit->getId();
         return "<script>window.rz_style_animation_scroll.push('" . $selector . "');</script>";
     } else {
         if ($api->isEditMode()) {
             $i18n = new Translator($api, $moduleInfo);
             $msg = $i18n->translate('error.insideExtensionModule');
             return '<script>alert("' . addslashes($msg) . '");</script>';
         }
     }
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:21,代码来源:rz_style_animation_scroll.php


示例17: getInstance

 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new Translator();
     }
     return self::$instance;
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:7,代码来源:Translator.php


示例18: cleanLanguagesDir

 /**
  * Clean up a languages dir
  *
  * @param string $dir Languages dir
  *
  * @return void
  */
 public function cleanLanguagesDir($dir)
 {
     $dir = rtrim($dir, '/\\');
     foreach (scandir($dir) as $entry) {
         if ($entry[0] === '.') {
             continue;
         }
         if (pathinfo($entry, PATHINFO_EXTENSION) !== 'php') {
             continue;
         }
         $path = "{$dir}/{$entry}";
         $code = basename($entry, '.php');
         if (!in_array($code, $this->codes)) {
             $code = Translator::normalizeLanguageCode($code);
             if (in_array($code, $this->codes)) {
                 // rename file to lowercase
                 rename($path, "{$dir}/{$code}.php");
                 $this->log[] = "Renamed {$path} to {$code}.php";
                 continue;
             }
             unlink($path);
             $this->log[] = "Removed {$path}";
         }
     }
 }
开发者ID:cyrixhero,项目名称:Elgg,代码行数:32,代码来源:ReleaseCleaner.php


示例19: getOne

    public static function getOne($id)
    {
        $data = array();
        $sql = '
			SELECT * FROM {{translator}}
			WHERE id=' . $id . '
		';
        $item = DB::getRow($sql);
        $sql = '
			SELECT * FROM {{translator}}
			WHERE parent=' . $item['id'] . '
		';
        $rows = DB::getALL($sql);
        foreach (Translator::getLanguage() as $ii => $lang) {
            if ($ii == 0) {
                $data[$item['lang']] = $item;
            } else {
                foreach ($rows as $row) {
                    if ($row['lang'] == $lang['value']) {
                        $data[$row['lang']] = $row;
                    }
                }
            }
        }
        return $data;
    }
开发者ID:sov-20-07,项目名称:billing,代码行数:26,代码来源:TranslatorModel.php


示例20: getTranslator

 /**
  * Get Translator
  *
  * Provides access to the Translator singleton
  *
  * @return Translator The translator object
  */
 public static function getTranslator()
 {
     if (self::$instance == null) {
         self::$instance = new Translator();
     }
     return self::$instance;
 }
开发者ID:carriercomm,项目名称:NeoBill,代码行数:14,代码来源:Translator.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TravelHelper类代码示例发布时间:2022-05-23
下一篇:
PHP Translations类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap