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.

    
    <?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。可在一般的英中和中英字典里都查不到这样的翻译。