Tag: english

  • A support class to pluralise English words in Magento

    我写这个类更多地是为了补习一下英文。顺便说一下,我会逐渐把更多的 support classes 归于 Msdk module,意思是 Magento SDK.

    An ideal way to learn IT and English as a foreign language at a time.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    <?php
    class Qian_Mdsk_Helper_Plural extends Mage_Core_Helper_Abstract
    {
    /**
    * auto is a wrapper. it calls another method by language settings
    * @param int $nr
    * @param string $singularWord
    * @return string
    */
    public static function auto($nr, $singularWord) {
    //if english
    return self::english($nr, $singularWord, 's');
    }
     
    public static function english($nr, $singularWord, $pluralSuffix = 's') {
    if (abs($nr) == 1) {
    return "$nr $singularWord";
    }
     
    $no = Mage::helper('corex')->__("No");
    //If a word has more than one form of plural, and if the commonly used form is regular, the word will not be included in this dictionary.
    //e.g. roof => roofs (irregular) or rooves (regular)
    $dictionary = array(
    //sh rule exception
    'fish' => 'fish',
     
    //o rule exception
    'canto' => 'cantos',
    'homo' => 'homos',
    'piano' => 'pianos',
    'portico' => 'porticos',
    'pro' => 'pros',
    'quarto' => 'quartos',
    'kimono' => 'kimonos',
    'zoo' => 'zoos',
    'igloo' => 'igloos',
    'kangaroo' => 'kangaroo',
    'kniazhestvo' => 'kniazhestva',
     
    //x rule exception
    'matrix' => 'matrices',
    'vertex' => 'vertices',
     
    //s rule exception
    'alumnus' => 'alumni',
    'corpus' => 'corpora',
    'focus' => 'foci',
    'genus' => 'genera',
    'prospectus' => 'prospecti',
    'radius' => 'radii',
    'syllabus' => 'syllabi',
    'viscus' => 'viscera',
    'fungus' => 'fungi',
    'terminus' => 'termini',
    'uterus' => 'uteri',
    'Atlas' => 'Atlantes',
     
    'species' => 'species',
    'series' => 'series',
    'blues' => 'blues',
    'axis' => 'axes',
    'testis' => 'testes',
     
    //y rule exception
    'Germany' => 'Germanys',
    'Harry' => 'Harrys',
     
    //f rule exception
    'staff' => 'staff',
    'flagstaff' => 'flagstaffs',
    'proof' => 'proofs',
     
    //other exception
    //singular and plural are identical
    'people' => 'people',
    'deer' => 'deer',
    'moose' => 'moose',
    'sheep' => 'sheep',
    'bison' => 'bison',
    'salmon' => 'salmon',
    'pike' => 'pike',
    'trout' => 'trout',
    'swine' => 'swine',
    'aircraft' => 'aircraft',
    'head' => 'head',
    'stone' => 'stone',
    'benshi' => 'benshi',
    'otaku' => 'otaku',
    'samurai' => 'samurai',
    'Māori' => 'Māori',
    'marae' => 'marae',
    'waka' => 'waka',
     
    //very irregular exception
    'child' => 'children',
     
    'alumna' => 'alumnae',
     
    'mouse' => 'mice',
    'louse' => 'lice',
     
    'tooth' => 'teeth',
    'foot' => 'feet',
    'goose' => 'geese',
     
    'automaton' => 'automata',
    'criterion' => 'criteria',
    'phenomenon' => 'phenomena',
    'polyhedron' => 'polyhedra',
     
    'addendum' => 'addenda',
    'agendum' => 'agenda',
    'consortium' => 'consortia',
    'corrigendum' => 'corrigenda',
    'datum' => 'data',
    'medium' => 'media',
    'memorandum' => 'memoranda',
    'millennium' => 'millennia',
    'symposium' => 'symposia',
     
    'stigma' => 'stigmata',
    'stoma' => 'stomata',
    'schema' => 'schemata',
    'dogma' => 'dogmata',
    'lemma' => 'lemmata',
     
    'beau' => 'beaux',
    'château' => 'châteaux',
    'tableau' => 'tableaux',
     
    'Inuk' => 'Inuit',
    'inukshuk' => 'inukshuit',
     
    'phalanx' => 'phalanges',
     
    );
     
    if (isset($dictionary[$singularWord])) {
    $pluralWord = $dictionary[$singularWord];
    }
    else {//some clever conversion
    $end = substr($singularWord, -3);
    if ($end == 'man') { //checking last 3 characters
    $pluralWord = substr($singularWord, 0, -3) . 'men';
    }
    elseif ($end == 'sis') {
    $pluralWord = substr($singularWord, 0, -3) . 'ses';
    }
    else {
    $end = substr($singularWord, -2);
    if ($end == 'ch' || $end == 'sh') {
    $pluralWord = $singularWord . 'es';
    }
    elseif ($end == 'fe') {
    $pluralWord = substr($singularWord, 0, -2) . 'ves'//e.g. knife => knives, wife => wives
    }
    else {
    $end = substr($singularWord, -1);
    if (strpos('sxo', $end) === false) { //checking last character
    $pluralWord = $singularWord . 'es';
    }
    elseif ($end == 'f') {
    $pluralWord = substr($singularWord, 0, -1) . 'ves'; //e.g. half => halves
    }
    elseif ($end == 'y') {
    $secondLast = substr($singularWord, -2, 1);
    if (strpos('aeiou', $secondLast) === false) {
    $pluralWord = substr($singularWord, 0, -1) . 'ies'; //e.g. lady => ladies
    }
    else {
    $pluralWord = $singularWord . $pluralSuffix; //e.g. boy => boys
    }
    }
    else { //last rule
    $pluralWord = $singularWord . $pluralSuffix;
    }
    }
    }
     
    }
     
    if ($nr == 0) {
    return "$no $pluralWord";
    }
    else {
    return "$nr $pluralWord";
    }
    }
     
    }
  • Badass and Caveats

    学到两个英文单词,Badass and Caveats,字典里不容易查到。

    Badass 竟然是褒义词,意思是很优秀的、非常好的。我看了金山词霸的翻译,是错的。

    如果把注意事项翻译为 Caveats 就很地道。可惜,拿 Google translate 英译中得到“注意事项”,但中译英只得到“notes“。

  • 乱码

    乱码的英文garbled。惭愧,一直跟着词霸说messy code,听得英国人越来越messy。

  • 6 sigma

    闲来无事的时候我听听six sigma (6 Σ)的讲座,初听尚不能把握6 Σ精髓所在。但至少有两点感悟:

    1. 对产品质量要求越高,并不一定带来更高生产成本。看来以前我都陷入了高成本才有高质量的思维定势。
    2. 主动的和被动的,最准确的英文翻译为proactive和reactive。可在一般的英中和中英字典里都查不到这样的翻译。