Show
Ignore:
Timestamp:
10/05/2007 03:12:01 PM (14 months ago)
Author:
Shadowhand
Message:

Small changes:

  • Implemented a work around for Profiler being displayed in external resources (scripts can be output with views with Profiler globally enabled)
  • Added inflector::uncountable($str)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/inflector.php

    r671 r673  
    33class inflector { 
    44 
    5         protected static $uncountables = array(); 
     5        public static function uncountable($str) 
     6        { 
     7                static $uncountables = NULL; 
     8 
     9                if ($uncountables === NULL) 
     10                { 
     11                        // Makes a mirrored array, eg: foo => foo 
     12                        $uncountables = array_combine(Kohana::lang('inflector'), Kohana::lang('inflector')); 
     13                } 
     14 
     15                return isset($uncountables[$str]); 
     16        } 
    617 
    718        public static function singular($str) 
     
    920                $str = trim($str); 
    1021 
    11                 if (empty(self::$uncountables)) 
    12                 { 
    13                         self::$uncountables = Kohana::lang('inflector'); 
    14                 } 
    15  
    1622                // We can just return uncountable words 
    17                 if (in_array(strtolower($str), self::$uncountables)) 
     23                if (self::uncountable($str)) 
    1824                        return $str; 
    1925 
     
    4349                $str = trim($str); 
    4450 
    45                 if (empty(self::$uncountables)) 
    46                 { 
    47                         self::$uncountables = Kohana::lang('inflector'); 
    48                 } 
    49  
    5051                // We can just return uncountable words 
    51                 if (in_array(strtolower($str), self::$uncountables)) 
     52                if (self::uncountable($str)) 
    5253                        return $str; 
    5354