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


PHP i18n::nc方法代码示例

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


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

示例1: build_notification

 /**
  * build a notification related to an article
  *
  * The action can be one of the following:
  * - 'apply' - surfer would like to get access to the page
  * - 'publish' - either a published page has been posted, or a draft page has been published
  * - 'submit' - a draft page has been posted
  * - 'update' - a page (draft or published) has been modified
  *
  * This function builds a mail message that displays:
  * - an image of the contributor (if possible)
  * - a headline mentioning the contribution
  * - the full content of the new comment
  * - a button linked to the reply page
  * - a link to the containing page
  *
  * Note: this function returns legacy HTML, not modern XHTML, because this is what most
  * e-mail client software can afford.
  *
  * @param string either 'apply', 'publish', 'submit' or 'update'
  * @param array attributes of the item
  * @param object overlay of the item, if any
  * @return string text to be send by e-mail
  */
 public static function build_notification($action = 'publish', $item, $overlay = NULL)
 {
     global $context;
     // sanity check
     if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
         throw new Exception('no anchor for this article');
     }
     // compute page title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // headline link to section
     $headline_link = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url() . '">' . $anchor->get_title() . '</a>';
     // headline template
     switch ($action) {
         case 'apply':
             $template = i18n::c('%s is requesting access to %s');
             $headline_link = '<a href="' . Articles::get_permalink($item) . '">' . $title . '</a>';
             break;
         case 'publish':
             $template = i18n::c('%s has posted a page in %s');
             break;
         case 'submit':
             $template = i18n::c('%s has submitted a page in %s');
             break;
         case 'update':
             $template = i18n::c('%s has updated a page in %s');
             break;
     }
     // headline
     $headline = sprintf($template, Surfer::get_link(), $headline_link);
     // panel content
     $content = '';
     // more insight on this page
     $prefix = $suffix = '';
     // signal articles to be published
     if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
         $prefix .= DRAFT_FLAG;
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // flag expired articles
     if (isset($item['expiry_date']) && $item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $prefix .= EXPIRED_FLAG . ' ';
     }
     // signal locked articles
     if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
         $suffix .= ' ' . LOCKED_FLAG;
     }
     // insert page title
     $content .= '<h3><span>' . $prefix . $title . $suffix . '</span></h3>';
     // insert anchor prefix
     if (is_object($anchor)) {
         $content .= $anchor->get_prefix();
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $content .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } elseif (isset($item['introduction']) && trim($item['introduction'])) {
         $content .= Skin::build_block($item['introduction'], 'introduction');
     }
     // get text related to the overlay, if any
     if (is_object($overlay)) {
         $content .= $overlay->get_text('diff', $item);
     }
     // filter description, if necessary
     if (is_object($overlay)) {
         $description = $overlay->get_text('description', $item);
     } else {
         $description = $item['description'];
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:articles.php

示例2: build_notification

 /**
  * build a notification related to a section
  *
  * This function builds a mail message that displays:
  * - an image of the contributor (if possible)
  * - a headline mentioning the contribution
  * - the full content of the section
  * - a button linked to the section
  * - a link to the containing section, if any
  *
  * Note: this function returns legacy HTML, not modern XHTML, because this is what most
  * e-mail client software can afford.
  *
  * @param string either 'apply', 'create' or 'update'
  * @param array attributes of the item
  * @param object overlay of the item, if any
  * @return string text to be send by e-mail
  */
 public static function build_notification($action, $item, $overlay = NULL)
 {
     global $context;
     // get the main anchor
     $anchor = Anchors::get($item['anchor']);
     // compute page title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // headline template
     switch ($action) {
         case 'apply':
             $template = i18n::c('%s is requesting access to %s');
             break;
         case 'create':
             $template = i18n::c('%s has created section %s');
             break;
         case 'update':
             $template = i18n::c('%s has updated section %s');
             break;
     }
     // headline
     $headline = sprintf($template, Surfer::get_link(), '<a href="' . Sections::get_permalink($item) . '">' . $title . '</a>');
     // panel content
     $content = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $title = PRIVATE_FLAG . $title;
     } elseif ($item['active'] == 'R') {
         $title = RESTRICTED_FLAG . $title;
     }
     // insert page title
     $content .= '<h3><span>' . $title . '</span></h3>';
     // insert anchor prefix
     if (is_object($anchor)) {
         $content .= $anchor->get_prefix();
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $content .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } elseif (isset($item['introduction']) && trim($item['introduction'])) {
         $content .= Skin::build_block($item['introduction'], 'introduction');
     }
     // get text related to the overlay, if any
     if (is_object($overlay)) {
         $content .= $overlay->get_text('view', $item);
     }
     // filter description, if necessary
     if (is_object($overlay)) {
         $description = $overlay->get_text('description', $item);
     } else {
         $description = $item['description'];
     }
     // the beautified description, which is the actual page body
     if ($description) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $content .= Skin::build_block($label, 'title');
         }
         // beautify the target page
         $content .= Skin::build_block($description, 'description', '', $item['options']);
     }
     // attachment details
     $details = array();
     // info on related sections
     if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d section', '%d sections', $count), $count);
     }
     // info on related articles
     if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d page', '%d pages', $count), $count);
     }
     // info on related files
     if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
         // the actual list of files attached to this section
         if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
             $items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         } else {
             $items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         }
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:sections.php

示例3: sprintf

}
//
// translations based on surfer preferences
//
$context['text'] .= Skin::build_block(i18n::s('Translation to surfer language'), 'title');
// simple label
$context['text'] .= '<p>' . i18n::s('This is a simple label, according to user preference') . '</p>';
// complex label
$context['text'] .= '<p>' . sprintf(i18n::s('This string, using surfer language, allows for argument reordering: %2$s %1$s'), 'hello', 'world') . '</p>';
// plural label for one item
$context['text'] .= '<p>' . sprintf(i18n::ns('There is %d item', 'There are %d items', 1), 1) . '</p>';
// plural label for several items
$context['text'] .= '<p>' . sprintf(i18n::ns('There is %d item', 'There are %d items', 7), 7) . '</p>';
// descriptive text
$context['text'] .= i18n::s('<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>');
//
// translations based on community preferences
//
$context['text'] .= Skin::build_block(i18n::c('Translation to community language'), 'title');
// simple label, translated using community preference
$context['text'] .= '<p>' . i18n::c('This is a simple label, according to community preference') . '</p>';
// complex label, translated using community preference
$context['text'] .= '<p>' . sprintf(i18n::c('This string, using community language, allows for argument reordering: %2$s %1$s'), 'hello', 'world') . '</p>';
// plural label for one item
$context['text'] .= '<p>' . sprintf(i18n::nc('There is %d item', 'There are %d items', 1), 1) . '</p>';
// plural label for several items
$context['text'] .= '<p>' . sprintf(i18n::nc('There is %d item', 'There are %d items', 7), 7) . '</p>';
// descriptive text
$context['text'] .= i18n::c('<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>');
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:test.php


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