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


PHP i18n::_t方法代码示例

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


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

示例1: getReportField

 function getReportField()
 {
     $tlf = parent::getReportField();
     $tlf->setFieldFormatting(array('Invoice' => '<a target=\\"_blank\\" href=\\"OrderReport_Popup/invoice/$ID\\">' . i18n::_t('VIEW', 'view') . '</a> ' . '<a target=\\"_blank\\" href=\\"OrderReport_Popup/index/$ID?print=1\\">' . i18n::_t('PRINT', 'print') . '</a>'));
     $tlf->setFieldCasting(array('Created' => 'Date->Long', 'Total' => 'Currency->Nice'));
     $tlf->setPermissions(array('edit', 'show', 'export', 'delete', 'print'));
     return $tlf;
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:8,代码来源:AllOrdersReport.php

示例2: printorder

 /**
  * Render order for printing
  */
 public function printorder()
 {
     Requirements::clear();
     //include print javascript, if print argument is provided
     if (isset($_REQUEST['print']) && $_REQUEST['print']) {
         Requirements::customScript("if(document.location.href.indexOf('print=1') > 0) {window.print();}");
     }
     $title = i18n::_t("ORDER.INVOICE", "Invoice");
     if ($id = $this->popupController->getRequest()->param('ID')) {
         $title .= " #{$id}";
     }
     return $this->record->customise(array('SiteConfig' => SiteConfig::current_site_config(), 'Title' => $title))->renderWith('OrderAdmin_Printable');
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:16,代码来源:OrdersAdmin.php

示例3: init

 function init()
 {
     parent::init();
     //include print javascript, if print argument is provided
     if (isset($_REQUEST['print']) && $_REQUEST['print']) {
         Requirements::customScript("if(document.location.href.indexOf('print=1') > 0) {window.print();}");
     }
     $this->Title = i18n::_t("ORDER.INVOICE", "Invoice");
     if ($id = $this->urlParams['ID']) {
         $this->Title .= " #{$id}";
     }
     /*Requirements::themedCSS("reset");*/
     /*Requirements::themedCSS("OrderReport");*/
     /*Requirements::themedCSS("OrderReport_Print", "print");*/
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:15,代码来源:OrderReport.php

示例4: testTranslate

 public function testTranslate()
 {
     i18n::set_locale('en_US');
     $this->assertEquals('Legacy translation', i18n::_t('i18nOtherModule.LEGACY'), 'Finds original strings in PHP module files');
     $this->assertEquals('Legacy translation', i18n::_t('i18nOtherModule.LEGACYTHEME'), 'Finds original strings in theme files');
     i18n::set_locale('de_DE');
     $this->assertEquals('Legacy translation (de_DE)', i18n::_t('i18nOtherModule.LEGACY'), 'Finds translations in PHP module files');
     $this->assertEquals('Legacy translation (de_DE)', i18n::_t('i18nOtherModule.LEGACYTHEME'), 'Finds original strings in theme files');
     // TODO Implement likely subtags solution
     // i18n::set_locale('de');
     // $this->assertEquals(
     // 	'Legacy translation (de_DE)',
     // 	// defined in i18nothermodule/lang/de_DE.php
     // 	i18n::_t('i18nOtherModule.LEGACY'),
     // 	'Finds translations in PHP module files if only language locale is set'
     // );
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:17,代码来源:i18nSSLegacyAdapterTest.php

示例5: _t

/**
 * @see i18n::_t()
 */
function _t($entity, $string = "", $priority = 40, $context = "")
{
    return i18n::_t($entity, $string, $priority, $context);
}
开发者ID:racontemoi,项目名称:shibuichi,代码行数:7,代码来源:Core.php

示例6: _t

/**
 * @see i18n::_t()
 */
function _t($entity, $string = "", $context = "", $injection = "")
{
    return i18n::_t($entity, $string, $context, $injection);
}
开发者ID:nzjoel,项目名称:sapphire,代码行数:7,代码来源:Core.php

示例7: testMultipleTranslators

 public function testMultipleTranslators()
 {
     // Looping through modules, so we can test the translation autoloading
     // Load non-exclusive to retain core class autoloading
     $classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false);
     SS_ClassLoader::instance()->pushManifest($classManifest);
     // Changed manifest, so we also need to unset all previously collected messages.
     // The easiest way to do this it to register a new adapter.
     $adapter = new Zend_Translate(array('adapter' => 'i18nRailsYamlAdapter', 'locale' => i18n::default_locale(), 'disableNotices' => true));
     i18n::register_translator($adapter, 'core');
     i18n::set_locale('en_US');
     $this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'Entity with "Double Quotes"');
     $this->assertEquals(i18n::_t('AdapterEntity1', 'AdapterEntity1'), 'AdapterEntity1', 'Falls back to default string if not found');
     // Add a new translator
     $translator = new Zend_Translate(array('adapter' => 'i18nTest_CustomTranslatorAdapter', 'disableNotices' => true));
     i18n::register_translator($translator, 'custom', 11);
     $this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY CustomAdapter (en_US)', 'Existing entities overruled by adapter with higher priority');
     $this->assertEquals(i18n::_t('AdapterEntity1', 'AdapterEntity1'), 'AdapterEntity1 CustomAdapter (en_US)', 'New entities only defined in new adapter are detected');
     // Add a second new translator to test priorities
     $translator = new Zend_Translate(array('adapter' => 'i18nTest_OtherCustomTranslatorAdapter', 'disableNotices' => true));
     i18n::register_translator($translator, 'othercustom_lower_prio', 5);
     $this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY CustomAdapter (en_US)', 'Adapter with lower priority loses');
     // Add a third new translator to test priorities
     $translator = new Zend_Translate(array('adapter' => 'i18nTest_OtherCustomTranslatorAdapter', 'disableNotices' => true));
     i18n::register_translator($translator, 'othercustom_higher_prio', 15);
     $this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY OtherCustomAdapter (en_US)', 'Adapter with higher priority wins');
     i18n::unregister_translator('custom');
     i18n::unregister_translator('othercustom_lower_prio');
     i18n::unregister_translator('othercustom_higher_prio');
     SS_ClassLoader::instance()->popManifest();
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:31,代码来源:i18nTest.php

示例8: run


//.........这里部分代码省略.........
         // Check if it has been modified or not
         $templateModified = false;
         if ($emailTemplate) {
             $templateModified = $emailTemplate->Created != $emailTemplate->LastEdited;
         }
         if (!$overwrite && $emailTemplate) {
             DB::alteration_message("Template with code <b>{$code}</b> already exists. Choose overwrite if you want to import again.", "repaired");
             continue;
         }
         if ($overwrite == 'soft' && $templateModified) {
             DB::alteration_message("Template with code <b>{$code}</b> has been modified by the user. Choose overwrite=hard to change.", "repaired");
             continue;
         }
         // Create a default title from code
         $title = explode('-', $code);
         $title = array_map(function ($item) {
             return ucfirst($item);
         }, $title);
         $title = implode(' ', $title);
         // Get content of the email
         $content = file_get_contents($filePath);
         // Analyze content to find incompatibilities
         $errors = array();
         if (strpos($content, '<% with') !== false) {
             $errors[] = 'Replace "with" blocks by plain calls to the variable';
         }
         if (strpos($content, '<% if') !== false) {
             $errors[] = 'If/else logic is not supported. Please create one template by use case or abstract logic into the model';
         }
         if (strpos($content, '<% loop') !== false) {
             $errors[] = 'Loops are not supported. Please create a helper method on the model to render the loop';
         }
         if (strpos($content, '<% sprintf') !== false) {
             $errors[] = 'You should not use sprintf to escape content, please use plain _t calls';
         }
         if (!empty($errors)) {
             echo "<div style='color:red'>Invalid syntax was found in '{$relativeFilePath}'. Please fix these errors before importing the template<ul>";
             foreach ($errors as $error) {
                 echo '<li>' . $error . '</li>';
             }
             echo '</ul></div>';
             continue;
         }
         // Parse language
         $collector = new i18nTextCollector();
         $entities = $collector->collectFromTemplate($content, $fileName, $module);
         $translationTable = array();
         foreach ($entities as $entity => $data) {
             if ($locales) {
                 foreach ($locales as $locale) {
                     i18n::set_locale($locale);
                     if (!isset($translationTable[$entity])) {
                         $translationTable[$entity] = array();
                     }
                     $translationTable[$entity][$locale] = i18n::_t($entity);
                 }
                 i18n::set_locale($defaultLocale);
             } else {
                 $translationTable[$entity] = array($defaultLocale => i18n::_t($entity));
             }
         }
         $contentLocale = array();
         foreach ($locales as $locale) {
             $contentLocale[$locale] = $content;
         }
         foreach ($translationTable as $entity => $translationData) {
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:67,代码来源:EmailImportTask.php

示例9: menu_title

 /**
  * Get menu title for this section (translated)
  *
  * @param string $class Optional class name if called on LeftAndMain directly
  * @param bool $localise Determine if menu title should be localised via i18n.
  * @return string Menu title for the given class
  */
 public static function menu_title($class = null, $localise = true)
 {
     if ($class && is_subclass_of($class, __CLASS__)) {
         // Respect oveloading of menu_title() in subclasses
         return $class::menu_title(null, $localise);
     }
     if (!$class) {
         $class = get_called_class();
     }
     // Get default class title
     $title = Config::inst()->get($class, 'menu_title', Config::FIRST_SET);
     if (!$title) {
         $title = preg_replace('/Admin$/', '', $class);
     }
     // Check localisation
     if (!$localise) {
         return $title;
     }
     return i18n::_t("{$class}.MENUTITLE", $title);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:27,代码来源:LeftAndMain.php

示例10: run

 public function run($request)
 {
     echo 'Run with ?clear=1 to clear empty database before running the task<br/>';
     echo 'Run with ?overwrite=1 to overwrite templates that exists in the cms<br/>';
     echo 'Run with ?templates=xxx,yyy to specify which template should be imported<br/>';
     echo 'Run with ?subsite=1 to create email templates in all subsites as well. Overwriting is based on main site.<br/>';
     echo '<hr/>';
     $overwrite = $request->getVar('overwrite');
     $clear = $request->getVar('clear');
     $templatesToImport = $request->getVar('templates');
     $importToSubsite = $request->getVar('subsite');
     $subsites = array();
     if ($importToSubsite) {
         $subsites = Subsite::get()->map();
     }
     if ($templatesToImport) {
         $templatesToImport = explode(',', $templatesToImport);
     }
     if ($clear == 1) {
         echo '<strong>Clear all email templates</strong><br/>';
         $emailTemplates = EmailTemplate::get();
         foreach ($emailTemplates as $emailTemplate) {
             $emailTemplate->delete();
         }
     }
     $o = singleton('EmailTemplate');
     $ignoredModules = self::config()->ignored_modules;
     if (!is_array($ignoredModules)) {
         $ignoredModules = array();
     }
     $locales = null;
     if (class_exists('Fluent') && Fluent::locale_names()) {
         if ($o->hasExtension('FluentExtension')) {
             $locales = array_keys(Fluent::locale_names());
         }
     }
     $defaultLocale = i18n::get_locale();
     $templates = SS_TemplateLoader::instance()->getManifest()->getTemplates();
     foreach ($templates as $t) {
         $isOverwritten = false;
         // Emails in mysite/email are not properly marked as emails
         if (isset($t['mysite']) && isset($t['mysite']['email'])) {
             $t['email'] = $t['mysite']['email'];
         }
         // Should be in the /email folder
         if (!isset($t['email'])) {
             continue;
         }
         $filePath = $t['email'];
         $fileName = basename($filePath, '.ss');
         // Should end with *Email
         if (!preg_match('/Email$/', $fileName)) {
             continue;
         }
         $relativeFilePath = str_replace(Director::baseFolder(), '', $filePath);
         $relativeFilePathParts = explode('/', trim($relativeFilePath, '/'));
         // Group by module
         $module = array_shift($relativeFilePathParts);
         // Ignore some modules
         if (in_array($module, $ignoredModules)) {
             continue;
         }
         array_shift($relativeFilePathParts);
         // remove /templates part
         $templateName = str_replace('.ss', '', implode('/', $relativeFilePathParts));
         $templateTitle = basename($templateName);
         // Create a default code from template name
         $code = strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $fileName));
         $code = preg_replace('/-email$/', '', $code);
         if (!empty($templatesToImport) && !in_array($code, $templatesToImport)) {
             echo "<div style='color:blue'>Template with code '{$code}' was ignored.</div>";
             continue;
         }
         $emailTemplate = EmailTemplate::get()->filter('Code', $code)->first();
         if (!$overwrite && $emailTemplate) {
             echo "<div style='color:blue'>Template with code '{$code}' already exists.</div>";
             continue;
         }
         // Create a default title from code
         $title = explode('-', $code);
         $title = array_map(function ($item) {
             return ucfirst($item);
         }, $title);
         $title = implode(' ', $title);
         // Get content of the email
         $content = file_get_contents($filePath);
         // Analyze content to find incompatibilities
         $errors = array();
         if (strpos($content, '<% with') !== false) {
             $errors[] = 'Replace "with" blocks by plain calls to the variable';
         }
         if (strpos($content, '<% if') !== false) {
             $errors[] = 'If/else logic is not supported. Please create one template by use case or abstract logic into the model';
         }
         if (strpos($content, '<% loop') !== false) {
             $errors[] = 'Loops are not supported. Please create a helper method on the model to render the loop';
         }
         if (strpos($content, '<% sprintf') !== false) {
             $errors[] = 'You should not use sprintf to escape content, please use plain _t calls';
         }
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-mandrill,代码行数:101,代码来源:EmailImportTask.php


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