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


PHP pluralize函数代码示例

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


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

示例1: add_taxonomy

 public function add_taxonomy($name, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         // We need to know the post type name, so the new taxonomy can be attached to it.
         $post_type_name = $this->post_type_name;
         // Taxonomy properties
         $taxonomy_name = uglify($name);
         $taxonomy_labels = $labels;
         $taxonomy_args = $args;
         if (!taxonomy_exists($taxonomy_name)) {
             //Capitilize the words and make it plural
             $name = beautify($name);
             $plural = pluralize($name);
             // Default labels, overwrite them with the given labels.
             $labels = array_merge(array('name' => _x($plural, 'taxonomy general name', $this->post_domain), 'singular_name' => _x($name, 'taxonomy singular name', $this->post_domain), 'search_items' => __('Search ' . $plural, $this->post_domain), 'all_items' => __('All ' . $plural, $this->post_domain), 'parent_item' => __('Parent ' . $name, $this->post_domain), 'parent_item_colon' => __('Parent ' . $name . ':', $this->post_domain), 'edit_item' => __('Edit ' . $name, $this->post_domain), 'update_item' => __('Update ' . $name, $this->post_domain), 'add_new_item' => __('Add New ' . $name, $this->post_domain), 'new_item_name' => __('New ' . $name . ' Name', $this->post_domain), 'menu_name' => __($name, $this->post_domain)), $taxonomy_labels);
             // Default arguments, overwitten with the given arguments
             $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false), $taxonomy_args);
             // Add the taxonomy to the post type
             add_action('init', function () use($taxonomy_name, $post_type_name, $args) {
                 register_taxonomy($taxonomy_name, $post_type_name, $args);
             });
         } else {
             add_action('init', function () use($taxonomy_name, $post_type_name) {
                 register_taxonomy_for_object_type($taxonomy_name, $post_type_name);
             });
         }
     }
 }
开发者ID:fritzdenim,项目名称:pangMoves,代码行数:28,代码来源:custom-post-type-helper-class.php

示例2: get_posted_records

 function get_posted_records()
 {
     $record_set = $this->controller->params['ActiveRecord'];
     if (!$record_set) {
         return;
     }
     foreach ($record_set as $class_name => $object_set) {
         foreach ($object_set as $id => $updated_fields) {
             if (preg_match('/new-.*/', $id)) {
                 $obj = new $class_name();
                 $action = 'new';
             } else {
                 $obj = new $class_name($id);
                 $action = 'updated';
             }
             $obj->mergeData($updated_fields);
             $posted_record_collection = $action . '_' . snake_case(pluralize($class_name));
             if (!isset($this->controller->{$posted_record_collection})) {
                 $this->controller->{$posted_record_collection} = array();
             }
             $this->controller->posted_records[$class_name][$action][] = $obj;
             $this->controller->{$posted_record_collection}[] = $obj;
         }
     }
 }
开发者ID:radicaldesigns,项目名称:gtd,代码行数:25,代码来源:DefaultFilterCollection.php

示例3: route_makeRequest

 public function route_makeRequest()
 {
     $type = pluralize(strip_tags($_GET['type']));
     set_time_limit(0);
     $fp = fopen("../{$type}/latest.zip", 'w+');
     $url = str_replace(" ", "%20", strip_tags($_GET['url']));
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_TIMEOUT, 50);
     curl_setopt($ch, CURLOPT_FILE, $fp);
     # write curl response to file
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     $zip = new ZipArchive();
     if ($zip->open("../{$type}/latest.zip") == true) {
         mkdir("../{$type}/latest", 0777);
         $zip->extractTo("../{$type}/latest");
         $zip->close();
         $handle = opendir("../{$type}/latest");
         if ($handle) {
             while (($file = readdir($handle)) !== false) {
                 if (is_dir("../{$type}/latest/{$file}")) {
                     if ($file != '.' and $file != '..') {
                         rename("../{$type}/latest/{$file}", "../{$type}/{$file}");
                     }
                 }
             }
         }
         $this->rrmdir("../{$type}/latest");
         unlink("../{$type}/latest.zip");
         $this->rrmdir("../{$type}/__MACOSX");
     }
     Flash::notice(__("Extension downloaded successfully.", "extension_manager"), "/admin/?action=extend_manager");
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:35,代码来源:extension_manager.php

示例4: test_irregular

 public function test_irregular()
 {
     foreach (require __DIR__ . '/cases/fr/irregular.php' as $singular => $plural) {
         $this->assertEquals($singular, singularize($plural, 'fr'));
         $this->assertEquals($plural, pluralize($singular, 'fr'));
     }
 }
开发者ID:buildwithcraft,项目名称:craft-utensils,代码行数:7,代码来源:frTest.php

示例5: testPluralizeObject

 public function testPluralizeObject()
 {
     // arrange
     // act
     $result = pluralize((object) ['Felix', 'Tom'], 'cat');
     // assert
     $this->assertEquals('2 cats', $result);
 }
开发者ID:npmweb,项目名称:laravel-helpers,代码行数:8,代码来源:StringHelpersTest.php

示例6: new_taxonomy

 /**
  * Create a new taxonomy.
  * 
  * @param string $name
  *   The name of the taxonomy.
  * @param $post_types
  * @param boolean $hierarchical (optional)
  * 
  * @ingroup helperfunc
  */
 function new_taxonomy($name, $post_types, $hierarchical = true)
 {
     if (!is_array($name)) {
         $name = array("singular" => $name, "plural" => pluralize($name));
     }
     $uc_plural = ucwords(preg_replace("/_/", " ", $name["plural"]));
     $uc_singular = ucwords(preg_replace("/_/", " ", $name["singular"]));
     $labels = array("name" => $uc_singular, "singular_name" => $uc_singular, "search_items" => sprintf(__("Search %s", "we"), $uc_plural), "all_items" => sprintf(__("All %s", "we"), $uc_plural), "parent_item" => sprintf(__("Parent %s", "we"), $uc_singular), "parent_item_colon" => sprintf(__("Parent %s:", "we"), $uc_singular), "edit_item" => sprintf(__("Edit %s", "we"), $uc_singular), "update_item" => sprintf(__("Update %s", "we"), $uc_singular), "add_new_item" => sprintf(__("Add new %s", "we"), $uc_singular), "new_item_name" => sprintf(__("New %n Name", "we"), $uc_singular), "menu_name" => $uc_plural);
     register_taxonomy($name["singular"], $post_types, array('hierarchical' => $hierarchical, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $name["plural"])));
 }
开发者ID:nebirhos,项目名称:wordless,代码行数:20,代码来源:model_helper.php

示例7: validates_confirmation_of

function validates_confirmation_of($model, $field, $options = array())
{
    $params = array_merge($_GET, $_POST);
    $model_name = strtolower(get_class($model));
    if (isset($params[$model_name][$field])) {
        if ($params[$model_name]["confirm_{$field}"] != $model->fields[$field]) {
            add_error_message_to($model, $field, !$options['custom_message'] ? pluralize(humanize($field)) . " do not match." : $options['custom_message']);
        }
        unset($model->fields["confirm_{$field}"]);
    }
}
开发者ID:russ,项目名称:jacks-php,代码行数:11,代码来源:validation.php

示例8: jal_time_since

function jal_time_since($original)
{
    if (!isset($_SESSION['Year'])) {
        $_SESSION['Year'] = __('year', wordspew);
        $_SESSION['years'] = __('years', wordspew);
        $_SESSION['Month'] = __('month', wordspew);
        $_SESSION['months'] = __('months', wordspew);
        $_SESSION['Week'] = __('week', wordspew);
        $_SESSION['weeks'] = __('weeks', wordspew);
        $_SESSION['Day'] = __('day', wordspew);
        $_SESSION['days'] = __('days', wordspew);
        $_SESSION['Hour'] = __('hour', wordspew);
        $_SESSION['hours'] = __('hours', wordspew);
        $_SESSION['Minute'] = __('minute', wordspew);
        $_SESSION['minutes'] = __('minutes', wordspew);
    }
    // array of time period chunks
    $chunks = array(array(60 * 60 * 24 * 365, $_SESSION['Year'], $_SESSION['years']), array(60 * 60 * 24 * 30, $_SESSION['Month'], $_SESSION['months']), array(60 * 60 * 24 * 7, $_SESSION['Week'], $_SESSION['weeks']), array(60 * 60 * 24, $_SESSION['Day'], $_SESSION['days']), array(60 * 60, $_SESSION['Hour'], $_SESSION['hours']), array(60, $_SESSION['Minute'], $_SESSION['minutes']));
    $original = $original - 10;
    // Shaves a second, eliminates a bug where $time and $original match.
    $today = time();
    /* Current unix time  */
    $since = $today - $original;
    // $j saves performing the count function each time around the loop
    for ($i = 0, $j = count($chunks); $i < $j; $i++) {
        $seconds = $chunks[$i][0];
        $name = $chunks[$i][1];
        $name_s = $chunks[$i][2];
        // finding the biggest chunk (if the chunk fits, break)
        if (($count = floor($since / $seconds)) != 0) {
            break;
        }
    }
    $print = $count . " " . pluralize($count, $name, $name_s);
    if ($i + 1 < $j) {
        // now getting the second item
        $seconds2 = $chunks[$i + 1][0];
        $name2 = $chunks[$i + 1][1];
        $name2_s = $chunks[$i + 1][2];
        // add second item if it's greater than 0
        if (($count2 = floor(($since - $seconds * $count) / $seconds2)) != 0) {
            $print .= ", " . $count2 . " " . pluralize($count2, $name2, $name2_s);
        }
    }
    return $print;
}
开发者ID:sontv1003,项目名称:vtcacademy,代码行数:46,代码来源:common.php

示例9: deliver

 function deliver($view, $data)
 {
     $headers = array();
     $headers[] = "From: {$this->from}";
     if (isset($this->reply_to)) {
         $headers[] = "Return-Path: {$this->reply_to}";
     }
     $class_name = strtolower(pluralize(str_replace('Mailer', '', get_class($this))));
     // Load HTML View
     if (!isset($this->html) && file_exists(APPLICATION_ROOT . "/app/views/{$class_name}/{$view}.php")) {
         ob_start();
         require APPLICATION_ROOT . "/app/views/{$class_name}/{$view}.php";
         $this->html = ob_get_contents();
         ob_end_clean();
     }
     // Load Text View
     if (!isset($this->text) && file_exists(APPLICATION_ROOT . "/app/views/{$class_name}/{$view}_text.php")) {
         ob_start();
         require APPLICATION_ROOT . "/app/views/{$class_name}/{$view}_text.php";
         $this->text = ob_get_contents();
         ob_end_clean();
     }
     $mime_boundary = '=' . md5(time());
     // Headers
     $headers[] = "From: {$this->from}";
     $headers[] = "MIME-Version: 1.0";
     $headers[] = "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"";
     // Mashed Body
     $body .= "--{$mime_boundary}\n";
     $body .= "Content-Type: text/plain; charset=iso-8859-1\n";
     $body .= "Content-Transfer-Encoding: 8bit\n\n";
     $body .= "{$this->text}\n\n";
     $body .= "--{$mime_boundary}\n";
     $body .= "Content-Type: text/html; charset=iso-8859-1\n";
     $body .= "Content-Transfer-Encoding: quoted-printable\n\n";
     $body .= "{$this->html}\n\n";
     $body .= "--{$mime_boundary}--\n\n";
     foreach ($this->recipients as $recipient) {
         mail($recipient, $this->subject, $body, join($headers, "\n"));
     }
 }
开发者ID:russ,项目名称:jacks-php,代码行数:41,代码来源:mailer.php

示例10: calculateDiff

function calculateDiff($dayDelta, $minuteDelta)
{
    if ($dayDelta != 'null' && $dayDelta != '0') {
        if ($dayDelta < 0) {
            $diff = "-" . pluralize(abs(intval($dayDelta)) . " day");
        } else {
            if ($dayDelta > 0) {
                $diff = "+" . pluralize(intval($dayDelta) . " day");
            }
        }
    } else {
        $diff = "";
    }
    if ($minuteDelta != 'null' && $minuteDelta != '0') {
        if ($minuteDelta < 0) {
            $diff .= "-" . pluralize(abs(intval($minuteDelta)) . " minute");
        } else {
            $diff .= "+" . pluralize(intval($minuteDelta) . " minute");
        }
    }
    return $diff;
}
开发者ID:enoram,项目名称:maintenance,代码行数:22,代码来源:events.php

示例11: age

/**
 * Returns the age of a date/time.
 *
 *		Usage example:
 *			{$order.date_created|age} # 27 minutes ago
 */
function age($params, $delay = 0)
{
    $date = is_array($params) && $params['of'] ? $params['of'] : $params;
    // Make sure we have a timestamp.
    $time = is_numeric($date) ? (int) $date : strtotime($date);
    $seconds_elapsed = time() - $time - $delay;
    // Seconds.
    if ($seconds_elapsed < 60) {
        return 'just now';
    } else {
        if ($seconds_elapsed >= 60 && $seconds_elapsed < 3600) {
            $age = floor($seconds_elapsed / 60) . ' ' . pluralize(array('word' => 'minute', 'if_many' => floor($seconds_elapsed / 60)));
        } else {
            if ($seconds_elapsed >= 3600 && $seconds_elapsed < 86400) {
                $age = floor($seconds_elapsed / 3600) . ' ' . pluralize(array('word' => 'hour', 'if_many' => floor($seconds_elapsed / 3600)));
            } else {
                if ($seconds_elapsed >= 86400 && $seconds_elapsed < 604800) {
                    $age = floor($seconds_elapsed / 86400) . ' ' . pluralize(array('word' => 'day', 'if_many' => floor($seconds_elapsed / 86400)));
                } else {
                    if ($seconds_elapsed >= 604800 && $seconds_elapsed < 2626560) {
                        $age = floor($seconds_elapsed / 604800) . ' ' . pluralize(array('word' => 'week', 'if_many' => floor($seconds_elapsed / 604800)));
                    } else {
                        if ($seconds_elapsed >= 2626560 && $seconds_elapsed < 31536000) {
                            $age = floor($seconds_elapsed / 2626560) . ' ' . pluralize(array('word' => 'month', 'if_many' => floor($seconds_elapsed / 2626560)));
                        } else {
                            if ($seconds_elapsed >= 31536000) {
                                $age = floor($seconds_elapsed / 31536000) . ' ' . pluralize(array('word' => 'year', 'if_many' => floor($seconds_elapsed / 31536000)));
                            }
                        }
                    }
                }
            }
        }
    }
    return "{$age} ago";
}
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:42,代码来源:age.php

示例12: filterText

<?php

if (!isset($this->twitchObj->data['memberCard']['memberID'])) {
    exit;
}
$twitchObj = $this->twitchObj;
?>


<div class='twitchCardContainer'>
	<div class='twitchPreview'>
	<?php 
if ($twitchObj->data['memberCard']['online']) {
    echo "\n\t\t\t\t<div class='twitchLiveIcon'></div>\n\t\t\t\t<div class='twitchGameOverlay'><img src='" . $twitchObj->getGameImageURL($twitchObj->data['memberCard']['game']) . "' onmouseover=\"showToolTip('" . filterText($twitchObj->data['memberCard']['game']) . "')\" onmouseout=\"hideToolTip()\"></div>\n\t\t\t\t<div class='twitchViewers'>" . number_format($twitchObj->data['memberCard']['viewers']) . " " . pluralize("viewer", $twitchObj->data['memberCard']['viewers']) . "</div>\n\t\t\t\t<a href='" . MAIN_ROOT . "plugins/twitch/?user=" . $twitchObj->data['memberCard']['memberInfo']['username'] . "'><img src='" . $twitchObj->data['memberCard']['rawData']['stream']['preview']['medium'] . "'></a>\n\t\t\t";
} else {
    echo "<a href='" . MAIN_ROOT . "plugins/twitch/?user=" . $twitchObj->data['memberCard']['memberInfo']['username'] . "'><img src='" . MAIN_ROOT . "plugins/twitch/images/offlinepreview.png'></a>";
}
?>
	
	</div>
	<div class='twitchChannelDescription ellipsis' title='<?php 
echo filterText($twitchObj->data['memberCard']['streamTitle']);
?>
'><?php 
echo $twitchObj->data['memberCard']['streamTitle'];
?>
</div>
	<div class='twitchChannelDescription'><?php 
echo $twitchObj->data['memberCard']['memberLink'];
?>
 streaming as <a href='http://twitch.tv/<?php 
开发者ID:nsystem1,项目名称:clanscripts,代码行数:31,代码来源:membercard.php

示例13: pluralize

function pluralize($what)
{
    if ($what == "this") {
        return "these";
    } else {
        if ($what == "has") {
            return "have";
        } else {
            if ($what == "is") {
                return "are";
            } else {
                if (str_ends_with($what, ")") && preg_match('/\\A(.*?)(\\s*\\([^)]*\\))\\z/', $what, $m)) {
                    return pluralize($m[1]) . $m[2];
                } else {
                    if (preg_match('/\\A.*?(?:s|sh|ch|[bcdfgjklmnpqrstvxz][oy])\\z/', $what)) {
                        if (substr($what, -1) == "y") {
                            return substr($what, 0, -1) . "ies";
                        } else {
                            return $what . "es";
                        }
                    } else {
                        return $what . "s";
                    }
                }
            }
        }
    }
}
开发者ID:vaskevich,项目名称:nu-admissions-review,代码行数:28,代码来源:helpers.php

示例14: table

 protected static function table()
 {
     return pluralize(dash(get_called_class()));
 }
开发者ID:jeremyboles,项目名称:dispatch-model,代码行数:4,代码来源:model.php

示例15: disable

 /**
  * Function: disable
  * Disables a module or feather.
  */
 public function disable()
 {
     $config = Config::current();
     $visitor = Visitor::current();
     $type = isset($_GET['module']) ? "module" : "feather";
     if (!$visitor->group->can("toggle_extensions")) {
         if ($type == "module") {
             show_403(__("Access Denied"), __("You do not have sufficient privileges to enable/disable modules."));
         } else {
             show_403(__("Access Denied"), __("You do not have sufficient privileges to enable/disable feathers."));
         }
     }
     if ($type == "module" and !module_enabled($_GET[$type])) {
         Flash::warning(__("Module already disabled."), "/admin/?action=modules");
     }
     if ($type == "feather" and !feather_enabled($_GET[$type])) {
         Flash::warning(__("Feather already disabled."), "/admin/?action=feathers");
     }
     $enabled_array = $type == "module" ? "enabled_modules" : "enabled_feathers";
     $folder = $type == "module" ? MODULES_DIR : FEATHERS_DIR;
     $class_name = camelize($_GET[$type]);
     if (method_exists($class_name, "__uninstall")) {
         call_user_func(array($class_name, "__uninstall"), false);
     }
     $config->set($type == "module" ? "enabled_modules" : "enabled_feathers", array_diff($config->{$enabled_array}, array($_GET[$type])));
     $info = YAML::load($folder . "/" . $_GET[$type] . "/info.yaml");
     if ($type == "module") {
         Flash::notice(_f("&#8220;%s&#8221; module disabled.", array($info["name"])), "/admin/?action=" . pluralize($type));
     } elseif ($type == "feather") {
         Flash::notice(_f("&#8220;%s&#8221; feather disabled.", array($info["name"])), "/admin/?action=" . pluralize($type));
     }
 }
开发者ID:eadz,项目名称:chyrp,代码行数:36,代码来源:Admin.php


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