Show
Ignore:
Timestamp:
03/19/09 10:40:34 (3 years ago)
Author:
john
Message:

features and bug fixes from gocoffeego project

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/inflections.php

    r201 r308  
    8181Inflections::irregular('sex', 'sexes');  
    8282Inflections::irregular('move', 'moves');  
     83Inflections::irregular('cow', 'kine');  
    8384 
    8485Inflections::uncountable('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); 
     
    9495class Inflections { 
    9596 
    96     public static $plurals = array(); 
    97  
    98     public static $singulars = array(); 
    99  
    100     public static $uncountables = array(); 
     97    public static  
     98        $plurals = array(), 
     99        $singulars = array(), 
     100        $uncountables = array(), 
     101        $humans = array(); 
    101102 
    102103    # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.  
     
    130131    #   Inflections::uncountable(array("money", "information", "rice")) 
    131132    function uncountable() { 
    132         $args = func_get_args(); 
     133        $args = func_get_args(); 
    133134        if(is_array($args[0])) { 
    134135            $args = $args[0];     
     
    137138            self::$uncountables[] = $word;     
    138139        }      
     140    } 
     141 
     142    # Specifies a humanized form of a string by a regular expression rule or by a string mapping. 
     143    # When using a regular expression based replacement, the normal humanize formatting is called after the replacement. 
     144    # When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name') 
     145    # 
     146    # Examples: 
     147    #   Inflections::human("/_cnt$/i", "\1_count") 
     148    #   Inflections::human("legacy_col_person_name", "Name") 
     149    function human($rule, $replacement) { 
     150        array_unshift(self::$humans, array("rule" => $rule, "replacement" => $replacement)); 
    139151    } 
    140152     
     
    147159    function clear($scope = "all") { 
    148160        if($scope == "all") { 
    149             self::$plurals = self::$singulars = self::$uncountables = array(); 
     161            self::$plurals = self::$singulars = self::$uncountables = self::$humans = array(); 
    150162        } else { 
    151163            self::$$scope = array();