當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::irregular方法代碼示例

本文整理匯總了PHP中Inflector::irregular方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::irregular方法的具體用法?PHP Inflector::irregular怎麽用?PHP Inflector::irregular使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inflector的用法示例。


在下文中一共展示了Inflector::irregular方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: plural

 /**
  * Makes a singular word plural.
  *
  * @param string $str word to pluralize
  * @param int $count
  * @return string
  */
 public static function plural($str, $count = NULL)
 {
     // Remove garbage
     $str = strtolower(trim($str));
     if (is_string($count)) {
         // Convert to integer when using a digit string
         $count = (int) $count;
     }
     // Do nothing with singular
     if ($count === 1) {
         return $str;
     }
     // Cache key name
     $key = 'plural_' . $str . $count;
     if (isset(self::$cache[$key])) {
         return self::$cache[$key];
     }
     if (self::uncountable($str)) {
         return self::$cache[$key] = $str;
     }
     if (empty(self::$irregular)) {
         // Cache irregular words
         self::$irregular = AetherDatabaseConfig::retrieve('inflector.irregular');
     }
     if (isset(self::$irregular[$str])) {
         $str = self::$irregular[$str];
     } elseif (preg_match('/[sxz]$/', $str) || preg_match('/[^aeioudgkprt]h$/', $str)) {
         $str .= 'es';
     } elseif (preg_match('/[^aeiou]y$/', $str)) {
         // Change "y" to "ies"
         $str = substr_replace($str, 'ies', -1);
     } else {
         $str .= 's';
     }
     // Set the cache and return
     return self::$cache[$key] = $str;
 }
開發者ID:voldern,項目名稱:aether-orm,代碼行數:44,代碼來源:Inflector.php

示例2: plural

 /**
  * Makes a singular word plural.
  *
  *     echo Inflector::plural('fish'); // "fish", uncountable
  *     echo Inflector::plural('cat');  // "cats"
  *
  * You can also provide the count to make inflection more intelligent.
  * In this case, it will only return the plural value if the count is
  * not one.
  *
  *     echo Inflector::singular('cats', 3); // "cats"
  *
  * [!!] Special inflections are defined in `config/inflector.php`.
  *
  * @param   string  $str   word to pluralize
  * @param   integer $count count of thing
  *
  * @return  string
  * @uses    Inflector::uncountable
  */
 public static function plural($str, $count = null)
 {
     // $count should always be a float
     $count = $count === null ? 0.0 : (double) $count;
     // Do nothing with singular
     if ($count == 1) {
         return $str;
     }
     // Remove garbage
     $str = trim($str);
     // Cache key name
     $key = 'plural_' . $str . $count;
     // Check uppercase
     $is_uppercase = ctype_upper($str);
     if (isset(Inflector::$cache[$key])) {
         return Inflector::$cache[$key];
     }
     if (Inflector::uncountable($str)) {
         return Inflector::$cache[$key] = $str;
     }
     if (empty(Inflector::$irregular)) {
         // Cache irregular words
         Inflector::$irregular = Kohana::$config->load('inflector')->irregular;
     }
     if (isset(Inflector::$irregular[$str])) {
         $str = Inflector::$irregular[$str];
     } elseif (in_array($str, Inflector::$irregular)) {
         // Do nothing
     } elseif (preg_match('/[sxz]$/', $str) or preg_match('/[^aeioudgkprt]h$/', $str)) {
         $str .= 'es';
     } elseif (preg_match('/[^aeiou]y$/', $str)) {
         // Change "y" to "ies"
         $str = substr_replace($str, 'ies', -1);
     } else {
         $str .= 's';
     }
     // Convert to uppercase if necessary
     if ($is_uppercase) {
         $str = strtoupper($str);
     }
     // Set the cache and return
     return Inflector::$cache[$key] = $str;
 }
開發者ID:s4urp8n,項目名稱:kohana-admin,代碼行數:63,代碼來源:Inflector.php

示例3: plural

 /**
  * Makes a singular word plural.
  *
  *     echo Inflector::plural('fish'); // "fish", uncountable
  *     echo Inflector::plural('cat');  // "cats"
  *
  * You can also provide the count to make inflection more intelligent.
  * In this case, it will only return the plural value if the count is
  * not one.
  *
  *     echo Inflector::singular('cats', 3); // "cats"
  *
  * [!!] Special inflections are defined in `config/inflector.php`.
  *
  * @param   string   word to pluralize
  * @param   integer  count of thing
  * @return  string
  * @uses    Inflector::uncountable
  */
 public static function plural($str, $count = NULL)
 {
     // $count should always be a float
     $count = $count === NULL ? 0.0 : (double) $count;
     // Do nothing with singular
     if ($count == 1) {
         return $str;
     }
     // Remove garbage
     $str = strtolower(trim($str));
     // Cache key name
     $key = 'plural_' . $str . $count;
     if (isset(Inflector::$cache[$key])) {
         return Inflector::$cache[$key];
     }
     if (Inflector::uncountable($str)) {
         return Inflector::$cache[$key] = $str;
     }
     if (empty(Inflector::$irregular)) {
         // Cache irregular words
         Inflector::$irregular = Kohana::config('inflector')->irregular;
     }
     if (isset(Inflector::$irregular[$str])) {
         $str = Inflector::$irregular[$str];
     } elseif (preg_match('/[sxz]$/', $str) or preg_match('/[^aeioudgkprt]h$/', $str)) {
         $str .= 'es';
     } elseif (preg_match('/[^aeiou]y$/', $str)) {
         // Change "y" to "ies"
         $str = substr_replace($str, 'ies', -1);
     } else {
         $str .= 's';
     }
     // Set the cache and return
     return Inflector::$cache[$key] = $str;
 }
開發者ID:joelpittet,項目名稱:core,代碼行數:54,代碼來源:inflector.php

示例4: reset

 /**
  * Clears all inflection rules.
  *
  * @param string|boolean $lang The language name to reset or `true` to reset all even defaults.
  */
 public static function reset($lang = null)
 {
     if (is_string($lang)) {
         unset(static::$_singular[$lang]);
         unset(static::$_plural[$lang]);
         return;
     }
     static::$_singular = [];
     static::$_plural = [];
     if ($lang === true) {
         return;
     }
     /**
      * Initilalize the class with english inflector rules.
      */
     Inflector::singular('/([^s])s$/i', '\\1', 'default');
     Inflector::plural('/([^s])$/i', '\\1s', 'default');
     Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\\1', 'default');
     Inflector::plural('/(x|z|ss|ch|sh)$/i', '\\1es', 'default');
     Inflector::singular('/ies$/i', 'y', 'default');
     Inflector::plural('/([^aeiouy]|qu)y$/i', '\\1ies', 'default');
     Inflector::plural('/(meta|data)$/i', '\\1', 'default');
     Inflector::irregular('child', 'children', 'default');
     Inflector::irregular('equipment', 'equipment', 'default');
     Inflector::irregular('information', 'information', 'default');
     Inflector::irregular('man', 'men', 'default');
     Inflector::irregular('news', 'news', 'default');
     Inflector::irregular('person', 'people', 'default');
     Inflector::irregular('woman', 'women', 'default');
     /**
      * Warning, using an "exhastive" list of rules will slow
      * down all singularizations/pluralizations generations.
      * So it may be preferable to only add the ones you are actually needed.
      *
      * Anyhow bellow a list english exceptions which are not covered by the above rules.
      */
     // Inflector::irregular('advice', 'advice', 'default');
     // Inflector::irregular('aircraft', 'aircraft', 'default');
     // Inflector::irregular('alias', 'aliases', 'default');
     // Inflector::irregular('alga', 'algae', 'default');
     // Inflector::irregular('alumna', 'alumnae', 'default');
     // Inflector::irregular('alumnus', 'alumni', 'default');
     // Inflector::irregular('analysis', 'analyses', 'default');
     // Inflector::irregular('antenna', 'antennae', 'default');
     // Inflector::irregular('automaton', 'automata', 'default');
     // Inflector::irregular('axis', 'axes', 'default');
     // Inflector::irregular('bacillus', 'bacilli', 'default');
     // Inflector::irregular('bacterium', 'bacteria', 'default');
     // Inflector::irregular('barracks', 'barracks', 'default');
     // Inflector::irregular('basis', 'bases', 'default');
     // Inflector::irregular('bellows', 'bellows', 'default');
     // Inflector::irregular('buffalo', 'buffaloes', 'default');
     // Inflector::irregular('bus', 'buses', 'default');
     // Inflector::irregular('bison', 'bison', 'default');
     // Inflector::irregular('cactus', 'cacti', 'default');
     // Inflector::irregular('cafe', 'cafes', 'default');
     // Inflector::irregular('calf', 'calves', 'default');
     // Inflector::irregular('cargo', 'cargoes', 'default');
     // Inflector::irregular('cattle', 'cattle', 'default');
     // Inflector::irregular('child', 'children', 'default');
     // Inflector::irregular('congratulations', 'congratulations', 'default');
     // Inflector::irregular('corn', 'corn', 'default');
     // Inflector::irregular('crisis', 'crises', 'default');
     // Inflector::irregular('criteria', 'criterion', 'default');
     // Inflector::irregular('curriculum', 'curricula', 'default');
     // Inflector::irregular('datum', 'data', 'default');
     // Inflector::irregular('deer', 'deer', 'default');
     // Inflector::irregular('die', 'dice', 'default');
     // Inflector::irregular('dregs', 'dregs', 'default');
     // Inflector::irregular('duck', 'duck', 'default');
     // Inflector::irregular('echo', 'echos', 'default');
     // Inflector::irregular('elf', 'elves', 'default');
     // Inflector::irregular('ellipsis', 'ellipses', 'default');
     // Inflector::irregular('embargo', 'embargoes', 'default');
     // Inflector::irregular('equipment', 'equipment', 'default');
     // Inflector::irregular('erratum', 'errata', 'default');
     // Inflector::irregular('evidence', 'evidence', 'default');
     // Inflector::irregular('eyeglasses', 'eyeglasses', 'default');
     // Inflector::irregular('fish', 'fish', 'default');
     // Inflector::irregular('focus', 'foci', 'default');
     // Inflector::irregular('foot', 'feet', 'default');
     // Inflector::irregular('fungus', 'fungi', 'default');
     // Inflector::irregular('gallows', 'gallows', 'default');
     // Inflector::irregular('genus', 'genera', 'default');
     // Inflector::irregular('goose', 'geese', 'default');
     // Inflector::irregular('gold', 'gold', 'default');
     // Inflector::irregular('grotto', 'grottoes', 'default');
     // Inflector::irregular('gymnasium', 'gymnasia', 'default');
     // Inflector::irregular('half', 'halves', 'default');
     // Inflector::irregular('headquarters', 'headquarters', 'default');
     // Inflector::irregular('hoof', 'hooves', 'default');
     // Inflector::irregular('hypothesis', 'hypotheses', 'default');
     // Inflector::irregular('information', 'information', 'default');
     // Inflector::irregular('graffito', 'graffiti', 'default');
     // Inflector::irregular('half', 'halves', 'default');
//.........這裏部分代碼省略.........
開發者ID:ssgonchar,項目名稱:inflector,代碼行數:101,代碼來源:Inflector.php

示例5:

Inflector::singular('/(cris|ax|test)es$/i', '\\1is');
Inflector::singular('/([octop|vir])i$/i', '\\1us');
Inflector::singular('/(alias|status)es$/i', '\\1');
Inflector::singular('/^(ox)en/i', '\\1');
Inflector::singular('/(vert|ind)ices$/i', '\\1ex');
Inflector::singular('/(matr)ices$/i', '\\1ix');
Inflector::singular('/(quiz)zes$/i', '\\1');
Inflector::plural('/$/', 's');
Inflector::plural('/s$/i', 's');
Inflector::plural('/(ax|test)is$/i', '\\1es');
Inflector::plural('/(octop|vir)us$/i', '\\1i');
Inflector::plural('/(alias|status)$/i', '\\1es');
Inflector::plural('/(bu)s$/i', '\\1ses');
Inflector::plural('/(buffal|tomat)o$/i', '\\1oes');
Inflector::plural('/([ti])um$/i', '\\1a');
Inflector::plural('/sis$/i', 'ses');
Inflector::plural('/(?:([^f])fe|([lr])f)$/i', '\\1\\2ves');
Inflector::plural('/(hive)$/i', '\\1s');
Inflector::plural('/([^aeiouy]|qu)y$/i', '\\1ies');
Inflector::plural('/([^aeiouy]|qu)ies$/i', '\\1y');
Inflector::plural('/(x|ch|ss|sh)$/i', '\\1es');
Inflector::plural('/(matr|vert|ind)ix|ex$/i', '\\1ices');
Inflector::plural('/([m|l])ouse$/i', '\\1ice');
Inflector::plural('/^(ox)$/i', '\\1en');
Inflector::plural('/(quiz)$/i', '\\1zes');
Inflector::irregular('person', 'people');
Inflector::irregular('man', 'men');
Inflector::irregular('child', 'children');
Inflector::irregular('sex', 'sexes');
Inflector::irregular('move', 'moves');
Inflector::uncountable(array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'deer', 'elk', 'cattle'));
開發者ID:pdeffendol,項目名稱:tingle,代碼行數:31,代碼來源:Inflector.php

示例6:

Inflector::singular('/(n)ews$/i', '\\1ews');
Inflector::singular('/([ti])a$/i', '\\1um');
Inflector::singular('/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i', '\\1\\2sis');
Inflector::singular('/(^analy)ses$/i', '\\1sis');
Inflector::singular('/([^f])ves$/i', '\\1fe');
Inflector::singular('/(hive)s$/i', '\\1');
Inflector::singular('/(tive)s$/i', '\\1');
Inflector::singular('/([lr])ves$/i', '\\1f');
Inflector::singular('/([^aeiouy]|qu)ies$/i', '\\1y');
Inflector::singular('/(s)eries$/i', '\\1eries');
Inflector::singular('/(m)ovies$/i', '\\1ovie');
Inflector::singular('/(x|ch|ss|sh)es$/i', '\\1');
Inflector::singular('/([m|l])ice$/i', '\\1ouse');
Inflector::singular('/(bus)es$/i', '\\1');
Inflector::singular('/(o)es$/i', '\\1');
Inflector::singular('/(shoe)s$/i', '\\1');
Inflector::singular('/(cris|ax|test)es$/i', '\\1is');
Inflector::singular('/(octop|vir)i$/i', '\\1us');
Inflector::singular('/(alias|status)es$/i', '\\1');
Inflector::singular('/^(ox)en/i', '\\1');
Inflector::singular('/(vert|ind)ices$/i', '\\1ex');
Inflector::singular('/(matr)ices$/i', '\\1ix');
Inflector::singular('/(quiz)zes$/i', '\\1');
Inflector::singular('/(database)s$/i', '\\1');
Inflector::irregular('person', 'people');
Inflector::irregular('man', 'men');
Inflector::irregular('child', 'children');
Inflector::irregular('sex', 'sexes');
Inflector::irregular('move', 'moves');
Inflector::irregular('cow', 'cattle');
Inflector::uncountable(array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans'));
開發者ID:phaseshift,項目名稱:starlightframework,代碼行數:31,代碼來源:inflections.php


注:本文中的Inflector::irregular方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。