本文整理汇总了PHP中ngettext函数的典型用法代码示例。如果您正苦于以下问题:PHP ngettext函数的具体用法?PHP ngettext怎么用?PHP ngettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ngettext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMainInfo
public function getMainInfo()
{
$user = User::getInstance(Stb::getInstance()->id);
$oss_info = $user->getInfoFromOSS();
$info = array('fname' => $user->getProfileParam('fname'), 'phone' => $user->getProfileParam('phone'), 'ls' => $user->getProfileParam('ls'), 'mac' => $user->getProfileParam('mac'));
if (is_array($oss_info)) {
$info = array_merge($info, $oss_info);
}
$info['last_change_status'] = $user->getProfileParam('last_change_status');
if (Config::getSafe('enable_internal_billing', false) && !array_key_exists('end_date', $info)) {
$expire_billing_date = $user->getProfileParam('expire_billing_date');
if (strtotime($expire_billing_date) > 0) {
$info['end_date'] = $expire_billing_date;
}
}
if (!array_key_exists('account_balance', $info) && $user->getProfileParam('account_balance') != '') {
$info['account_balance'] = $user->getProfileParam('account_balance');
}
if (array_key_exists('end_date', $info)) {
$end_time = strtotime($info['end_date']);
if ($end_time) {
$days = ceil(($end_time - time()) / (24 * 3600));
/// in format of php date() function
$info['end_date'] = date(_('end_date_format'), strtotime($info['end_date'])) . ' (' . sprintf(ngettext('%d day', '%d days', $days), $days) . ')';
}
}
if (Config::get('enable_tariff_plans')) {
$info['tariff_plan'] = $user->getTariffPlanName();
}
return $info;
}
示例2: getPluralText
public static function getPluralText($singular, $plural, $number)
{
if (self::_getTextMode() == self::GETTEXT_MODE_NATIVE) {
return ngettext($singular, $plural, $number);
}
return _ngettext($singular, $plural, $number);
}
示例3: ShowResultsEditSurvey
/**
* GForge Survey Facility
*
* Portions Copyright 1999-2001 (c) VA Linux Systems
* The rest Copyright 2002-2004 (c) GForge Team
* http://gforge.org/
*
* @version $Id$
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function ShowResultsEditSurvey($result)
{
global $group_id;
$rows = db_NumRows($result);
$cols = db_NumFields($result);
echo "<h3>" . sprintf(ngettext('%1$s survey found', '%1$s surveys found', $rows), $rows) . "</h3>";
if ($rows > 0) {
echo "<table border=\"0\">\n";
/* Create the headers */
echo "<tr class=\"tableheading\">\n";
for ($i = 0; $i < $cols; $i++) {
echo "<th>" . db_fieldname($result, $i) . "</th>\n";
}
echo "</tr>";
for ($j = 0; $j < $rows; $j++) {
echo "<tr class=\".{$HTML->boxGetAltRowStyle}({$j})\">\n";
echo "<td><a href=\"edit_survey.php?group_id={$group_id}&survey_id=" . db_result($result, $j, 0) . "\">" . db_result($result, $j, 0) . "</a></td>";
for ($i = 1; $i < $cols; $i++) {
echo "<td>" . db_result($result, $j, $i) . "</td>\n";
}
echo "</tr>";
}
echo "</table>";
}
}
示例4: execute
/**
* Purge completed tasks that were completed before the configured date.
*
* @return boolean Whether any messages were purged from the mailbox.
*/
public function execute()
{
global $injector, $prefs;
/* Get the current UNIX timestamp minus the number of days specified
* in 'purge_completed_keep'. If a task has a timestamp prior to
* this value, it will be deleted. */
$del_time = new Horde_Date($_SERVER['REQUEST_TIME'] - $prefs->getValue('purge_completed_keep') * 86400);
$del_time = $del_time->timestamp();
$tasklists = Nag::listTasklists(true, Horde_Perms::DELETE, false);
$tasks = Nag::listTasks(array('completed' => Nag::VIEW_COMPLETE, 'tasklists' => array_keys($tasklists)));
$factory = $GLOBALS['injector']->getInstance('Nag_Factory_Driver');
$count = 0;
$tasks->reset();
while ($task = $tasks->each()) {
if ($task->completed_date && $task->completed_date < $del_time || !$task->completed_date && $task->modified && $task->modified->timestamp() < $del_time) {
try {
$factory->create($task->tasklist)->delete($task->id);
++$count;
} catch (Nag_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
}
}
}
$GLOBALS['notification']->push(sprintf(ngettext("Purging %d completed task.", "Purging %d completed tasks.", $count), $count), 'horde.message');
return true;
}
示例5: datas
public function datas($msgId1 = '', $msgId2 = '', $count = 0)
{
if (!is_string($msgId1) || !is_string($msgId2)) {
return Error::set(lang('Error', 'stringParameter', '1.(msgId1) & 2.(msgId2)'));
}
return ngettext($msgId1, $msgId2, $count);
}
示例6: initItem
public function initItem()
{
parent::initItem();
if (is_object($GLOBALS['user']) && $GLOBALS['user']->id != 'nobody') {
if (WidgetHelper::hasWidget($GLOBALS['user']->id, 'News')) {
$news = StudipNews::CountUnread();
}
if (Config::get()->VOTE_ENABLE && WidgetHelper::hasWidget($GLOBALS['user']->id, 'Evaluations')) {
$threshold = Config::get()->NEW_INDICATOR_THRESHOLD ? strtotime("-{" . Config::get()->NEW_INDICATOR_THRESHOLD . "} days 0:00:00") : 0;
$statement = DBManager::get()->prepare("\n SELECT COUNT(*)\n FROM questionnaire_assignments\n INNER JOIN questionnaires ON (questionnaires.questionnaire_id = questionnaire_assignments.questionnaire_id)\n WHERE questionnaire_assignments.range_id = 'start'\n AND questionnaires.visible = 1\n AND questionnaires.startdate IS NOT NULL\n AND questionnaires.startdate > UNIX_TIMESTAMP()\n AND questionnaires.startdate > :threshold\n AND (questionnaires.stopdate IS NULL OR questionnaires.stopdate <= UNIX_TIMESTAMP())\n ");
$statement->execute(array('threshold' => $threshold));
$vote = (int) $statement->fetchColumn();
$query = "SELECT COUNT(IF(chdate > IFNULL(b.visitdate, :threshold) AND d.author_id != :user_id, a.eval_id, NULL))\n FROM eval_range a\n INNER JOIN eval d ON (a.eval_id = d.eval_id AND d.startdate < UNIX_TIMESTAMP() AND\n (d.stopdate > UNIX_TIMESTAMP() OR d.startdate + d.timespan > UNIX_TIMESTAMP() OR (d.stopdate IS NULL AND d.timespan IS NULL)))\n LEFT JOIN object_user_visits b ON (b.object_id = d.eval_id AND b.user_id = :user_id AND b.type = 'eval')\n WHERE a.range_id = 'studip'\n GROUP BY a.range_id";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':user_id', $GLOBALS['user']->id);
$statement->bindValue(':threshold', ($threshold = Config::get()->NEW_INDICATOR_THRESHOLD) ? strtotime("-{$threshold} days 0:00:00") : 0);
$statement->execute();
$vote += (int) $statement->fetchColumn();
}
}
$homeinfo = _('Zur Startseite');
if ($news) {
$homeinfo .= ' - ';
$homeinfo .= sprintf(ngettext('%u neue Ankündigung', '%u neue Ankündigungen', $news), $news);
}
if ($vote) {
$homeinfo .= ' - ';
$homeinfo .= sprintf(ngettext('%u neuer Fragebogen', '%u neue Fragebögen', $vote), $vote);
}
$this->setBadgeNumber($vote + $news);
$this->setImage(Icon::create('home', 'navigation', ["title" => $homeinfo]));
}
示例7: initItem
public function initItem()
{
global $user, $neux;
parent::initItem();
$my_messaging_settings = UserConfig::get($user->id)->MESSAGING_SETTINGS;
$lastVisitedTimestamp = isset($my_messaging_settings['last_box_visit']) ? (int) $my_messaging_settings['last_box_visit'] : 0;
$query = "SELECT SUM(mkdate > :time AND readed = 0) AS num_new,\n SUM(readed = 0) AS num_unread,\n SUM(readed = 1) AS num_read\n FROM message_user\n WHERE snd_rec = 'rec' AND user_id = :user_id AND deleted = 0";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':time', $lastVisitedTimestamp);
$statement->bindValue(':user_id', $GLOBALS['user']->id);
$statement->execute();
list($neux, $neum, $altm) = $statement->fetch(PDO::FETCH_NUM);
$this->setBadgeNumber($neum);
if ($neux > 0) {
$tip = sprintf(ngettext('Sie haben %d neue ungelesene Nachricht', 'Sie haben %d neue ungelesene Nachrichten', $neux), $neux);
} else {
if ($neum > 1) {
$tip = sprintf(ngettext('Sie haben %d ungelesene Nachricht', 'Sie haben %d ungelesene Nachrichten', $neum), $neum);
} else {
if ($altm > 1) {
$tip = sprintf(ngettext('Sie haben %d alte empfangene Nachricht', 'Sie haben %d alte empfangene Nachrichten', $altm), $altm);
} else {
$tip = _('Sie haben keine alten empfangenen Nachrichten');
}
}
}
$this->setImage(Icon::create('mail', 'navigation', ["title" => $tip]));
}
示例8: humanReadable
/**
* Convert a time in seconds to human readable string
*
* @param int $diff The time in seconds
* @param int $precisionType The precision type for the string
* @param int $precision The precision
* The number of element if type is by format
* The number of character if type is by characters
* @return string
*/
public static function humanReadable($diff, $precisionType = 1, $precision = 1)
{
/* List of format in Date interval */
$listFormat = array('y' => array('year', 'years'), 'm' => array('month', 'months'), 'd' => array('day', 'days'), 'h' => array('hour', 'hours'), 'i' => array('min', 'min'), 's' => array('sec', 'sec'));
$dateInterval = new DateInterval($diff);
$formatedStr = '';
$newFormatedStr = '';
$count = 0;
/* Prepare string */
foreach ($listFormat as $format => $words) {
if ($dateInterval->{$format} > 0) {
if (strlen($newFormatedStr) > 0) {
$newFormatedStr .= ' ';
}
$newFormatedStr .= $dateInterval->{$format} . ' ' . ngettext($words[0], $words[1], $dateInterval->{$format});
$count++;
}
/* Test for precision type format */
if ($precisionType == self::PRECISION_FORMAT && $count >= $precision) {
return $newFormatedStr;
}
/* Test for precision type character */
if ($precisionType == self::PRECISION_CHAR && strlen($newFormatedStr) >= $precision) {
if ($formatedStr === '') {
return $newFormatedStr;
}
return $formatedStr;
}
$formatedStr = $newFormatedStr;
}
return $formatedStr;
}
示例9: isValid
/**
*/
public function isValid(&$var, &$vars, $value, &$message)
{
$value = trim($value);
if (empty($value)) {
if ($var->isRequired()) {
$message = _("This field is required.");
return false;
}
return true;
}
$invalid = array();
$rfc822 = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822');
foreach (explode("\n", $value) as $address) {
try {
$rfc822->parseAddressList($address, array('validate' => true));
} catch (Horde_Mail_Exception $e) {
$invalid[] = $address;
}
}
if (count($invalid)) {
$message = sprintf(ngettext(_("\"%s\" is not a valid email address."), _("\"%s\" are not valid email addresses."), count($invalid)), implode(', ', $invalid));
return false;
}
return true;
}
示例10: _renderInfo
/**
* Return the rendered information about the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _renderInfo()
{
global $registry;
if ($registry->getView() == $registry::VIEW_MINIMAL) {
return array();
}
$status = array();
$mime_id = $this->_mimepart->getMimeId();
$headers = Horde_Mime_Headers::parseHeaders($this->getConfigParam('imp_contents')->getBodyPart($mime_id, array('length' => 0, 'mimeheaders' => true, 'stream' => true))->data);
if (($duration = $headers->getValue('content-duration')) !== null) {
$text = array();
if ($minutes = floor($duration / 60)) {
$text[] = sprintf(ngettext(_("%d minute"), _("%d minutes"), $minutes), $minutes);
}
if ($seconds = $duration % 60) {
$text[] = sprintf(ngettext(_("%d second"), _("%d seconds"), $seconds), $seconds);
}
$status[] = sprintf(_("This video file is reported to be %s in length."), implode(' ', $text));
}
if ($this->_thumbnailBinary()) {
$status[] = _("This is a thumbnail of a video attachment.");
$status[] = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', '<img src="' . $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('imp_video_view' => 'view_thumbnail'))) . '" />', null, null, null);
}
if (empty($status)) {
return array();
}
$s = new IMP_Mime_Status($status);
$s->icon('mime/video.png');
return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $s, 'type' => 'text/html; charset=UTF-8'));
}
示例11: GetPath
function GetPath($path)
{
$fullPath = system\Helper::arcGetPath(true) . "assets/" . $path . "/";
$webPath = system\Helper::arcGetPath() . "assets" . $path;
$files = scandir($fullPath);
$html = "";
foreach ($files as $file) {
if ($file != "." && $file != "..") {
$html .= "<tr>" . "<td style=\"width: 10px;\"><input type=\"checkbox\" id=\"{$file}\" onchange=\"mark('{$path}/{$file}')\"><label for=\"{$file}\"></label></td>";
if (is_dir($fullPath . $file)) {
// folder
$fi = new FilesystemIterator($fullPath . $file, FilesystemIterator::SKIP_DOTS);
$html .= "<td><i class=\"fa fa-folder-o\"></i> <a class=\"clickable\" onclick=\"getFolderPath('{$path}/{$file}')\">{$file}</a></td>" . "<td style=\"width: 10px;\">folder</td>" . "<td style=\"width: 10px;\">-</td>" . "<td style=\"width: 100px;\">" . iterator_count($fi) . ngettext(" item", " items", iterator_count($fi)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
} else {
// get file type
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$filetype = finfo_file($finfo, $fullPath . $file);
finfo_close($finfo);
// file
$html .= "<td><i class=\"" . GetFileTypeIcon($filetype) . "\"></i> <a class=\"clickable\" onclick=\"viewFile('{$webPath}/{$file}', '{$filetype}', '" . FileSizeConvert(filesize($fullPath . $file)) . "', '" . date("d M Y", filectime($fullPath . $file)) . "')\">{$file}<a/></td>" . "<td style=\"width: 10px;\">{$filetype}</td>" . "<td style=\"width: 10px;\"><a alt=\"Copy link to clipboard\" class=\"clickable\" onclick=\"copyToClipboard('{$webPath}/{$file}')\"><i class=\"fa fa-link\"></i></a></td>" . "<td style=\"width: 100px;\">" . FileSizeConvert(filesize($fullPath . $file)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
}
$html .= "</tr>";
}
}
// no files
if (count($files) == 2) {
$html .= "<tr><td colspan=\"4\" class=\"text-center\">Folder is empty.</td></tr>";
}
return $html;
}
示例12: printMarksCount
function printMarksCount($num)
{
if ($num > 0) {
return sprintf(ngettext('%s mark', '%s marks', $num), $num);
} else {
return _('No marks');
}
}
示例13: describe
/**
* Return information for the login task.
*
* @return string Description of what the operation is going to do during
* this login.
*/
public function describe()
{
$mbox_list = array();
foreach ($this->_getMboxes() as $val) {
$mbox_list[] = $val->display_html;
}
return sprintf(ngettext("All messages in the mailbox \"%s\" older than %s days will be permanently deleted.", "All messages in the mailboxes \"%s\" older than %s days will be permanently deleted.", count($mbox_list)), implode(', ', $mbox_list), $GLOBALS['prefs']->getValue('purge_sentmail_keep'));
}
示例14: blacklistMessage
/**
* Adds the From address from the message(s) to the blacklist and deletes
* the message(s).
*
* @param IMP_Indices $indices An indices object.
* @param boolean $show_link Show link to the blacklist management in
* the notification message?
*
* @return boolean True if the messages(s) were deleted.
* @throws Horde_Exception
*/
public function blacklistMessage($indices, $show_link = true)
{
if (!$this->_processBWlist($indices, _("your blacklist"), 'blacklistFrom', 'showBlacklist', $show_link) || !($msg_count = $GLOBALS['injector']->getInstance('IMP_Message')->delete($indices))) {
return false;
}
$GLOBALS['notification']->push(ngettext("The message has been deleted.", "The messages have been deleted.", $msg_count), 'horde.message');
return true;
}
示例15: nt
/**
* Plural version of t()
*
* @param string $string1
* @param string $string2
* @param int $n
* @param string $textDomain Textdomain to use
* @return string
*/
public function nt($string1, $string2, $n, $textDomain = null)
{
if (empty($textDomain)) {
return ngettext($string1, $string2, $n);
} else {
return dngettext($textDomain, $string1, $string2, $n);
}
}