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


PHP T_ngettext函数代码示例

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


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

示例1: writeTagsProposition

function writeTagsProposition($tagsCloud, $title)
{
    static $id = 0;
    ++$id;
    echo <<<JS
    \$('.edit-tagclouds')
        .append(
'<div class="collapsible" id="edit-tagcloud-{$id}">'
+ '  <h3>{$title}</h3>'
+ '  <p class="popularTags tags"></p>'
+ '</div>');
JS;
    $taglist = '';
    foreach (array_keys($tagsCloud) as $key) {
        $row = $tagsCloud[$key];
        $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
        $taglist .= '<span' . ' title="' . $row['bCount'] . ' ' . $entries . '"' . ' style="font-size:' . $row['size'] . '"' . ' onclick="addTag(this)">' . filter($row['tag']) . '</span> ';
    }
    echo '$(\'#edit-tagcloud-' . $id . ' p\').append(' . json_encode($taglist) . ");\n";
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:20,代码来源:dynamictags.inc.php

示例2: foreach

<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is <strong>not</strong> supported on your system, using custom gettext implementation.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print T_("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(T_ngettext("%d pig went to the market\n", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:29,代码来源:pigs_fallback.php

示例3: smarty_block_t

/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text,
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, $smarty)
{
    // stop smarty from rendering on the opening tag
    if (!$text) {
        return;
    }
    $text = stripslashes($text);
    // set escape mode
    if ($params['escape'] !== null) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if ($params['plural'] !== null) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if ($params['count'] !== null) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if ($count !== null and $plural !== null) {
        $text = T_ngettext($text, $plural, $count);
        // vain: prefixed "T_" for usage of php-gettext
    } else {
        // use normal
        $text = T_gettext($text);
        // vain: prefixed "T_" for usage of php-gettext
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (false === isset($escape) or $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif ($escape !== null) {
        switch ($escape) {
            case 'javascript':
            case 'js':
                // javascript escape
                $text = str_replace('\'', '\\\'', stripslashes($text));
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    if ($text !== null) {
        return $text;
    }
}
开发者ID:Clansuite,项目名称:Clansuite,代码行数:70,代码来源:block.t.php

示例4: translatePlural

 function translatePlural($msg, $plural, $count)
 {
     if (defined('_poMMo_gettext')) {
         return T_ngettext($msg, $plural, $count);
     }
     return ngettext($msg, $plural, $count);
 }
开发者ID:systemfirez,项目名称:poMMo,代码行数:7,代码来源:Pommo_Helper_L10n.php

示例5: smarty_block_t

/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text, 
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, &$smarty)
{
    $text = stripslashes($text);
    // set escape mode
    if (isset($params['escape'])) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if (isset($params['plural'])) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if (isset($params['count'])) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if (isset($count) && isset($plural)) {
        $text = T_ngettext($text, $plural, $count);
    } else {
        // use normal
        $text = T_gettext($text);
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (!isset($escape) || $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif (isset($escape)) {
        switch ($escape) {
            case 'javascript':
            case 'js':
            case 'json':
                // javascript escape {12-12-2007, mike: modified for JSON support in ZMG}
                $json =& zmgFactory::getJSON();
                $text = $json->encode($text);
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    return $text;
}
开发者ID:BGCX261,项目名称:zoom-gallery-svn-to-git,代码行数:64,代码来源:block.t.php

示例6: smarty_block_t

/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text,
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, &$smarty)
{
    if (!$text) {
        return;
    }
    $text = stripslashes($text);
    // set escape mode
    if (isset($params['escape'])) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if (isset($params['plural'])) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if (isset($params['count'])) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if (isset($count) && isset($plural)) {
        $text = T_ngettext($text, $plural, $count);
    } else {
        // use normal
        $text = T_gettext($text);
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (!isset($escape) || $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif (isset($escape)) {
        switch ($escape) {
            case 'javascript':
            case 'js':
                // javascript escape
                $text = str_replace('\'', '\\\'', stripslashes($text));
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    return $text;
}
开发者ID:Sheogorath-SI,项目名称:magirc,代码行数:65,代码来源:block.t.php

示例7: displayRelatedTagsList

function displayRelatedTagsList($output, $current_tags, $current_page = "tags.php?tag=")
{
    $strResult = "";
    if ($output != null) {
        $strResult = "<table class=\"related_tags\">";
        foreach ($output as $current_row) {
            $resultsStr = T_ngettext('bookmark', 'bookmarks', $current_row['amount']);
            $strResult .= "<tr><td style=\"width: 1em; text-align: center;\"><a href=\"" . $current_page . $current_tags . "+" . $current_row['title'] . "\" title=\"" . T_("Add tag") . "\" alt=\"" . T_("Add tag") . "\">+</a></td><td style=\"margin-left: 0.5em;\"><a href=\"" . $current_page . $current_row['title'] . "\" title=\"" . $current_row['amount'] . " {$resultsStr}\">" . $current_row['title'] . "</a></td></tr>\n";
        }
        $strResult .= "</table>";
    }
    return $strResult;
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:13,代码来源:tags_functions.php

示例8: foreach

<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is <strong>not</strong> supported on your system, using custom gettext implementation.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print T_("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(gettext("Address Name"));
    print sprintf(T_ngettext("%d  Address Name", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>
开发者ID:TrinityComputers,项目名称:inoERP,代码行数:30,代码来源:pigs_fallback.php

示例9: importAddressCsv


//.........这里部分代码省略.........
             // FCMS
             $zip = $address['zip'];
         } elseif (isset($address['Home Postal Code'])) {
             // Outlook
             $zip = $address['Home Postal Code'];
         } elseif (isset($address['Address 1 - Postal Code'])) {
             // Gmail
             $zip = $address['Address 1 - Postal Code'];
         }
         // Phone Numbers
         $home = '';
         $work = '';
         $cell = '';
         // FCMS
         if (isset($address['home'])) {
             $home = $address['home'];
         }
         if (isset($address['work'])) {
             $work = $address['work'];
         }
         if (isset($address['cell'])) {
             $cell = $address['cell'];
         }
         // Outlook
         if (isset($address['Home Phone'])) {
             $home = $address['Home Phone'];
         }
         if (isset($address['Business Phone'])) {
             $work = $address['Business Phone'];
         }
         if (isset($address['Mobile Phone'])) {
             $cell = $address['Mobile Phone'];
         }
         // Gmail
         if (isset($address['Phone 1 - Type'])) {
             switch ($address['Phone 1 - Type']) {
                 case 'Home':
                     $home = $address['Phone 1 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 1 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 1 - Value'];
                     break;
             }
         }
         if (isset($address['Phone 2 - Type'])) {
             switch ($address['Phone 2 - Type']) {
                 case 'Home':
                     $home = $address['Phone 2 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 2 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 2 - Value'];
                     break;
             }
         }
         if (isset($address['Phone 3 - Type'])) {
             switch ($address['Phone 3 - Type']) {
                 case 'Home':
                     $home = $address['Phone 3 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 3 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 3 - Value'];
                     break;
             }
         }
         // Create non-member
         $uniq = uniqid("");
         $pw = 'NONMEMBER';
         if (isset($_POST['private'])) {
             $pw = 'PRIVATE';
         }
         $sql = "INSERT INTO `fcms_users`\n                        (`access`, `joindate`, `fname`, `lname`, `email`, `username`, `phpass`)\n                    VALUES (3, NOW(), ?, ?, ?, 'NONMEMBER-{$uniq}', ?)";
         $params = array($fname, $lname, $email, $pw);
         $id = $this->fcmsDatabase->insert($sql, $params);
         if ($id === false) {
             $this->fcmsError->displayError();
             return;
         }
         // Create address for non-member
         $sql = "INSERT INTO `fcms_address`\n                        (`user`, `created_id`, `created`, `updated_id`, `updated`, `address`, `city`, `state`, `zip`, `home`, `work`, `cell`)\n                    VALUES\n                        (?, ?, NOW(), ?, NOW(), ?, ?, ?, ?, ?, ?, ?)";
         $params = array($id, $this->fcmsUser->id, $this->fcmsUser->id, $street, $city, $state, $zip, $home, $work, $cell);
         if ($this->fcmsDatabase->insert($sql, $params)) {
             $this->fcmsError->displayError();
             return;
         }
         $i++;
     }
     echo '
         <p class="ok-alert">
             ' . sprintf(T_ngettext('%d Address Added Successfully', '%d Addresses Added Successfully', $i), $i) . '
         </p>';
 }
开发者ID:lmcro,项目名称:fcms,代码行数:101,代码来源:addressbook_class.php

示例10: get_formatted_timediff

function get_formatted_timediff($then, $timeout = 24, $now = false)
{
    $then = strtotime($then);
    define('INT_SECOND', 1);
    define('INT_MINUTE', 60);
    define('INT_HOUR', 3600);
    define('INT_DAY', 86400);
    define('INT_WEEK', 604800);
    $now = !$now ? time() : $now;
    $timediff = $now - $then;
    $weeks = (int) intval($timediff / INT_WEEK);
    $timediff = (int) intval($timediff - INT_WEEK * $weeks);
    $days = (int) intval($timediff / INT_DAY);
    $timediff = (int) intval($timediff - INT_DAY * $days);
    $hours = (int) intval($timediff / INT_HOUR);
    $timediff = (int) intval($timediff - INT_HOUR * $hours);
    $mins = (int) intval($timediff / INT_MINUTE);
    $timediff = (int) intval($timediff - INT_MINUTE * $mins);
    $sec = (int) intval($timediff / INT_SECOND);
    $timediff = (int) intval($timediff - $sec * INT_SECOND);
    if ($hours < $timeout && $days < 1 && $weeks < 1) {
        $str = '';
        if ($weeks) {
            $str .= intval($weeks);
            $str .= ' ' . T_ngettext('week', 'weeks', $weeks);
        }
        if ($days) {
            $str .= $str ? ', ' : '';
            $str .= intval($days);
            $str .= ' ' . T_ngettext('day', 'days', $days);
        }
        if ($hours) {
            $str .= $str ? ', ' : '';
            $str .= intval($hours);
            $str .= ' ' . T_ngettext('hour', 'hours', $hours);
        }
        if ($mins) {
            $str .= $str ? ', ' : '';
            $str .= intval($mins);
            $str .= ' ' . T_ngettext('minute', 'minutes', $mins);
        }
        if ($sec) {
            $str .= $str ? ', ' : '';
            $str .= intval($sec);
            $str .= ' ' . T_ngettext('second', 'seconds', $sec);
        }
        if (!$weeks && !$days && !$hours && !$mins && !$sec) {
            $str .= T_('0 seconds ago');
        } else {
            $str = sprintf(T_('%s ago'), $str);
        }
    }
    return $str;
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:54,代码来源:convert_date.php

示例11: count

                    if (empty($results[$row['bid']])) {
                        $results[$row['bid']] = 0;
                    }
                    $results[$row['bid']] += 2 * (100 - $total_rows / $total_bookmarks * 100) / $mod;
                }
            }
        }
        $number_of_results = count($results) + count($group_results);
    }
    include 'bheader.php';
    if ($keywords != null) {
        echo "<br><b>" . T_("Search") . " -- " . T_("Results") . "</b>";
        if ($number_of_results == 0) {
            $number_of_results = "" . T_("No") . "";
        }
        $resultsStr = T_ngettext('result', 'results', $number_of_results);
        // Added all the entities stripslashes stuff to the search results. [LBS 20020211]
        echo "<p><b>{$number_of_results}</b> {$resultsStr} " . T_("for") . " \"<b>" . htmlentities(stripslashes($keywords)) . "</b>\"";
    } else {
        echo "<br><b>" . T_("Search in your own bookmarks") . "</b>";
    }
    ?>
		<!-- Search Box -->

		<p>
		<form method="post">
		<input type='hidden' name='action' value='search' />
		<input name='keywords' value="" size="30" value="<?php 
    echo htmlentities(stripslashes($keywords));
    ?>
" class="formtext" onfocus="this.select()" />
开发者ID:noikiy,项目名称:owaspbwa,代码行数:31,代码来源:search.php

示例12: displayMembersListPage

 /**
  * displayMembersListPage 
  * 
  * @return void
  */
 function displayMembersListPage()
 {
     $this->displayHeader();
     $sql = "SELECT v.`id`, COUNT(*) AS 'count', v.`created_id` AS 'user_id', u.`fname`, u.`lname`, u.`avatar`, u.`gravatar`\n                FROM `fcms_video` AS v\n                LEFT JOIN `fcms_users` AS u ON v.`created_id` = u.`id`\n                WHERE `active` = 1\n                GROUP BY v.`created_id`\n                ORDER BY v.`updated` DESC";
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     echo '
     <div id="sections_menu">
         <ul>
             <li><a href="video.php">Latest Videos</a></li>
         </ul>
     </div>
     <ul id="large_video_users">';
     foreach ($rows as $row) {
         $name = cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']);
         $avatarPath = getAvatarPath($row['avatar'], $row['gravatar']);
         echo '
         <li>
             <a href="?u=' . $row['user_id'] . '"><img src="' . $avatarPath . '" alt="' . $name . '"/></a><br/>
             <a href="?u=' . $row['user_id'] . '">' . $name . '</a>
             <span>' . sprintf(T_ngettext('%d video', '%d videos', $row['count']), $row['count']) . '</span>
         </li>';
     }
     echo '
     </ul>
 </div>';
     $this->displayFooter();
 }
开发者ID:lmcro,项目名称:fcms,代码行数:37,代码来源:video.php

示例13: ngettext

                                $unit = ngettext('month ago', 'months ago', $interval);
                            } else {
                                if ($interval < 631138519) {
                                    $interval = floor($interval / 31556926);
                                    $unit = ngettext('year ago', 'years ago', $interval);
                                } else {
                                    $interval = floor($interval / 315569260);
                                    $unit = ngettext('decade ago', 'decades ago', $interval);
                                }
                            }
                        }
                    }
                }
            }
        }
        $time_string = sprintf('%d ' . T_ngettext($unit, $unit, $interval), $interval);
    }
    $song->format();
    ?>
    <tr class="<?php 
    echo UI::flip_class();
    ?>
">
        <td class="cel_play">
            <span class="cel_play_content">&nbsp;</span>
            <div class="cel_play_hover">
            <?php 
    if (AmpConfig::get('directplay')) {
        ?>
                <?php 
        echo Ajax::button('?page=stream&action=directplay&playtype=song&song_id=' . $song->id, 'play', T_('Play'), 'play_song_' . $nb . '_' . $song->id);
开发者ID:axelsimon,项目名称:ampache,代码行数:31,代码来源:show_recently_played.inc.php

示例14: getHumanTimeSince

/**
 * getHumanTimeSince 
 * 
 * Returns a nice, human readable difference between two dates.
 * ex: "5 days", "24 minutes"
 *
 * to time will be set to time() if not supplied
 * 
 * @param int $from 
 * @param int $to 
 * 
 * @return void
 */
function getHumanTimeSince($from, $to = 0)
{
    if ($to == 0) {
        $to = time();
    }
    $diff = (int) abs($to - $from);
    // now
    if ($diff < 1) {
        $since = T_('right now');
    } elseif ($diff < 60) {
        $since = sprintf(T_ngettext('%s second ago', '%s seconds ago', $diff), $diff);
    } elseif ($diff <= 3600) {
        $mins = round($diff / 60);
        if ($mins <= 1) {
            $mins = 1;
        }
        $since = sprintf(T_ngettext('%s minute ago', '%s minutes ago', $mins), $mins);
    } elseif ($diff <= 86400 && $diff > 3600) {
        $hours = round($diff / 3600);
        if ($hours <= 1) {
            $hours = 1;
        }
        $since = sprintf(T_ngettext('%s hour ago', '%s hours ago', $hours), $hours);
    } elseif ($diff >= 86400) {
        $days = round($diff / 86400);
        if ($days <= 1) {
            $days = 1;
        }
        $since = sprintf(T_ngettext('%s day ago', '%s days ago', $days), $days);
    }
    return $since;
}
开发者ID:lmcro,项目名称:fcms,代码行数:45,代码来源:datetime.php

示例15: T_

$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
    $logged_on_userid = NULL;
}
$popularTags =& $b2tservice->getPopularTags($userid, $popCount, $logged_on_userid);
$popularTags =& $b2tservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
if ($popularTags && count($popularTags) > 0) {
    ?>

<h2><?php 
    echo T_('Popular Tags');
    ?>
</h2>
<div id="popular">
    <p class="tags">
    <?php 
    $contents = '';
    if (strlen($user) == 0) {
        $cat_url = createURL('tags', '%2$s');
    }
    foreach ($popularTags as $row) {
        $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
        $contents .= '<a href="' . sprintf($cat_url, $user, filter($row['tag'], 'url')) . '" title="' . $row['bCount'] . ' ' . $entries . '" rel="tag" style="font-size:' . $row['size'] . '">' . filter($row['tag']) . '</a> ';
    }
    echo $contents . "\n";
    ?>
    </p>
</div>

<?php 
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:31,代码来源:sidebar.block.popular.php


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