1. PHP / Говнокод #23497

    −3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    <?
    
    Plural::setLanguage(basename(__FILE__, '.php'));
    
    # each rule is a regular expression and its replacement
    Plural::addRules(array(
        '/(matr|vert|ind)(ix|ex)$/i'    => '\1ices',    # matrix, vertex, index
        '/(ss|sh|ch|x|z)$/i'            => '\1es',      # sibilant rule (no ending e)
        '/([^aeiou])o$/i'               => '\1oes',     # -oes rule
        '/([^aeiou]|qu)y$/i'            => '\1ies',     # -ies rule
        '/sis$/i'                       => 'ses',       # synopsis, diagnosis
        '/(m|l)ouse$/i'                 => '\1ice',     # mouse, louse
        '/(t|i)um$/i'                   => '\1a',       # datum, medium
        '/([li])fe?$/i'                 => '\1ves',     # knife, life, shelf
        '/(octop|vir|syllab)us$/i'      => '\1i',       # octopus, virus, syllabus
        '/(ax|test)is$/i'               => '\1es',      # axis, testis
        '/([a-rt-z])$/i'                => '\1s'        # not ending in s
    ));
    
    # words that don't follow any pluralization rules
    Plural::addIrregulars(array(
        'bus'           => 'busses',
        'child'         => 'children',
        'man'           => 'men',
        'person'        => 'people',
        'quiz'          => 'quizzes',
        # words whose singular and plural forms are the same
        'equipment'     => 'equipment',
        'fish'          => 'fish',
        'information'   => 'information',
        'money'         => 'money',
        'moose'         => 'moose',
        'news'          => 'news',
        'rice'          => 'rice',
        'series'        => 'series',
        'sheep'         => 'sheep',
        'species'       => 'species'
    ));

    Удобная и быстрая бибилотека для плюралайза
    https://github.com/mjackson/plural/tree/master/lib

    Запостил: SemaReal, 07 Ноября 2017

    Комментарии (1) RSS

    Добавить комментарий