r82230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82229‎ | r82230 | r82231 >
Date:10:27, 16 February 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Follow-up r81074, r81517: implement SI prefixes as a separate structure. You can now specify which units should take SI, and then they accept *all* SI prefixes centrally. Some care is still needed to avoid unit conflicts, but this substantially reduces the number of messages required.

The translations of prefixed units in some languages may be a little tricky if the prefix is inflected etc, but you know what? You can always use ParserFunctions!! :-D
Modified paths:
  • /trunk/extensions/ParserFunctions/Convert.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/Convert.php
@@ -19,8 +19,11 @@
2020 const UNITS_REGEX = '/^(.+?)([a-z]+\^?\d?(?:\/\w+\^?\d?)*)$/i';
2121
2222 # A regex which matches a number
23 - const NUM_REGEX = '/\b((?:\+|\-|−|\x2212)?(\d+(?:\.\d+)?)(?:E(?:\+|\-|−|\x2212)?\d+)?)\b/i';
 23+ const NUM_REGEX = '/\b((?:\+|\-|−|\x{2212})?(\d+(?:\.\d+)?)(?:E(?:\+|\-|−|\x{2212})?\d+)?)\b/iu';
2424
 25+ # A regex *FRAGMENT* which matches SI prefixes
 26+ const PREFIX_REGEX = '[YZEPTGMkh(da)dcm\x{03BC}\x{00B5}npfazy]?';
 27+
2528 # ConvertUnit objects
2629 protected $sourceUnit;
2730 protected $targetUnit;
@@ -464,138 +467,148 @@
465468 * DIMENSION => array(
466469 * UNIT => array(
467470 * CONVERSION,
468 - * REGEX
 471+ * REGEX,
 472+ * TAKES_SI_PREFIXES,
469473 * )
470474 * )
471475 * )
472476 */
473477 protected static $units = array(
474478 ConvertDimension::DIM_LENGTH => array(
475 - 'gigametre' => array( 1000000000, 'Gm' ),
476 - 'megametre' => array( 1000000, 'Mm' ), # Case-sensitivity is forced
477 - 'kilometre' => array( 1000, 'km' ),
478 - 'hectometre' => array( 100, 'hm' ),
479 - 'decametre' => array( 10, 'dam' ),
480 - 'metre' => array( 1, 'm' ),
481 - 'decimetre' => array( 0.1, 'dm' ),
482 - 'centimetre' => array( 0.01, 'cm' ),
483 - 'millimetre' => array( 0.001, 'mm' ), # Case-sensitivity is forced
484 - 'micrometre' => array( 0.0001, '\x03BCm|\x00B5m|um' ), # There are two similar mu characters
485 - 'nanometre' => array( 0.0000001, 'nm' ),
486 - 'angstrom' => array( 0.00000001, '\x00C5' ),
 479+ 'metre' => array( 1, 'm', true ),
 480+ 'angstrom' => array( 0.00000001, '\x{00C5}', false ),
487481
488 - 'mile' => array( 1609.344, 'mi|miles?' ),
489 - 'furlong' => array( 201.168, 'furlong' ),
490 - 'chain' => array( 20.1168 , 'chain' ),
491 - 'rod' => array( 5.0292, 'rod|pole|perch' ),
492 - 'fathom' => array( 1.8288, 'fathom' ),
493 - 'yard' => array( 0.9144, 'yards?|yd' ),
494 - 'foot' => array( 0.3048, 'foot|feet|ft' ),
495 - 'hand' => array( 0.1016, 'hands?' ),
496 - 'inch' => array( 0.0254, 'inch|inches|in' ),
 482+ 'mile' => array( 1609.344, 'mi|miles?', false ),
 483+ 'furlong' => array( 201.168, 'furlong', false ),
 484+ 'chain' => array( 20.1168 , 'chain', false ),
 485+ 'rod' => array( 5.0292, 'rod|pole|perch', false ),
 486+ 'fathom' => array( 1.8288, 'fathom', false ),
 487+ 'yard' => array( 0.9144, 'yards?|yd', false ),
 488+ 'foot' => array( 0.3048, 'foot|feet|ft', false ),
 489+ 'hand' => array( 0.1016, 'hands?', false ),
 490+ 'inch' => array( 0.0254, 'inch|inches|in', false ),
497491
498 - 'nauticalmile' => array( 1852, 'nauticalmiles?|nmi' ),
499 - 'nauticalmileuk' => array( 1853.184, 'old[Uu][Kk]nmi|[Bb]rnmi|admi' ),
500 - 'nauticalmileus' => array( 1853.24496, 'old[Uu][Ss]nmi' ),
 492+ 'nauticalmile' => array( 1852, 'nauticalmiles?|nmi', false ),
 493+ 'nauticalmileuk' => array( 1853.184, 'old[Uu][Kk]nmi|[Bb]rnmi|admi', false ),
 494+ 'nauticalmileus' => array( 1853.24496, 'old[Uu][Ss]nmi', false ),
501495
502 - 'gigaparsec' => array( 3.0856775813057E25, 'gigaparsecs?|Gpc' ),
503 - 'megaparsec' => array( 3.0856775813057E22, 'megaparsecs?|Mpc' ),
504 - 'kiloparsec' => array( 3.0856775813057E19, 'kiloparsecs?|kpc' ),
505 - 'parsec' => array( 3.0856775813057E16, 'parsecs?|pc' ),
506 - 'gigalightyear' => array( 9.4607304725808E24, 'gigalightyears?|Gly' ),
507 - 'mrgalightyear' => array( 9.4607304725808E21, 'megalightyears?|Mly' ),
508 - 'kilolightyear' => array( 9.4607304725808E18, 'kilolightyears?|kly' ),
509 - 'lightyear' => array( 9.4607304725808E15, 'lightyears?|ly' ),
510 - 'astronomicalunit' => array( 149597870700, 'astronomicalunits?|AU|au' ),
 496+ 'parsec' => array( 3.0856775813057E16, 'parsecs?|pc', true ),
 497+ 'lightyear' => array( 9.4607304725808E15, 'lightyears?|ly', true ),
 498+ 'astronomicalunit' => array( 149597870700, 'astronomicalunits?|AU|au', false ),
511499 ),
512500
513501 ConvertDimension::DIM_AREA => array(
514 - 'squarekilometre' => array( 1E6, 'km2|km\^2' ),
515 - 'squaremetre' => array( 1, 'm2|m\^2' ),
516 - 'squarecentimetre' => array( 1E-4, 'cm2|cm\^2' ),
517 - 'squaremillimetre' => array( 1E-6, 'mm2|mm\^2' ),
518 - 'hectare' => array( 1E4, 'hectares?|ha' ),
 502+ 'squarekilometre' => array( 1E6, 'km2|km\^2', false ),
 503+ 'squaremetre' => array( 1, 'm2|m\^2', false ),
 504+ 'squarecentimetre' => array( 1E-4, 'cm2|cm\^2', false ),
 505+ 'squaremillimetre' => array( 1E-6, 'mm2|mm\^2', false ),
 506+ 'hectare' => array( 1E4, 'hectares?|ha', false ),
519507
520 - 'squaremile' => array( 2589988.110336, 'sqmi|mi2|mi\^2' ),
521 - 'acre' => array( 4046.856422 , 'acres?' ),
522 - 'squareyard' => array( 0.83612736, 'sqyd|yd2|yd\^2' ),
523 - 'squarefoot' => array( 0.09290304, 'sqft|ft2|ft\^2' ),
524 - 'squareinch' => array( 0.00064516, 'sqin|in2|in\^2' ),
 508+ 'squaremile' => array( 2589988.110336, 'sqmi|mi2|mi\^2', false ),
 509+ 'acre' => array( 4046.856422, 'acres?', false ),
 510+ 'squareyard' => array( 0.83612736, 'sqyd|yd2|yd\^2', false ),
 511+ 'squarefoot' => array( 0.09290304, 'sqft|ft2|ft\^2', false ),
 512+ 'squareinch' => array( 0.00064516, 'sqin|in2|in\^2', false ),
525513
526 - 'squarenauticalmile' => array( 3429904, 'sqnmi|nmi2|nmi\^2' ),
527 - 'dunam' => array( 1000, 'dunam' ),
528 - 'tsubo' => array( 3.305785, 'tsubo' ),
 514+ 'squarenauticalmile' => array( 3429904, 'sqnmi|nmi2|nmi\^2', false ),
 515+ 'dunam' => array( 1000, 'dunam', false ),
 516+ 'tsubo' => array( 3.305785, 'tsubo', false ),
529517 ),
530518
531519 ConvertDimension::DIM_VOLUME => array(
532 - 'cubicmetre' => array( 1, 'm3|m\^3' ),
533 - 'cubiccentimetre' => array( 1E-6, 'cm3|cm\^3' ),
534 - 'cubicmillimetre' => array( 1E-9, 'mm3|mm\^3' ),
535 - 'kilolitre' => array( 1, 'kl' ),
536 - 'litre' => array( 1E-3 , 'l' ),
537 - 'centilitre' => array( 1E-5, 'cl' ),
538 - 'millilitre' => array( 1E-6, 'ml' ),
 520+ 'cubicmetre' => array( 1, 'm3|m\^3', false ),
 521+ 'cubiccentimetre' => array( 1E-6, 'cm3|cm\^3', false ),
 522+ 'cubicmillimetre' => array( 1E-9, 'mm3|mm\^3', false ),
 523+ 'litre' => array( 1E-3 , 'l', true ),
539524
540 - 'cubicyard' => array( 0.764554857984, 'cuyd|yd3|yd\^3' ),
541 - 'cubicfoot' => array( 0.028316846592, 'cuft|ft3|ft\^3' ),
542 - 'cubicinch' => array( 0.000016387064, 'cuin|in3|in\^3' ),
543 - 'barrel' => array( 0.16365924, 'bbl|barrels?|impbbl' ),
544 - 'bushel' => array( 0.03636872, 'bsh|bushels?|impbsh' ),
545 - 'gallon' => array( 0.00454609, 'gal|gallons?|impgal' ),
546 - 'quart' => array( 0.0011365225, 'qt|quarts?|impqt' ),
547 - 'pint' => array( 0.00056826125, 'pt|pints?|imppt' ),
548 - 'fluidounce' => array( 0.0000284130625, 'floz|impfloz' ),
 525+ 'cubicyard' => array( 0.764554857984, 'cuyd|yd3|yd\^3', false ),
 526+ 'cubicfoot' => array( 0.028316846592, 'cuft|ft3|ft\^3', false ),
 527+ 'cubicinch' => array( 0.000016387064, 'cuin|in3|in\^3', false ),
 528+ 'barrel' => array( 0.16365924, 'bbl|barrels?|impbbl', false ),
 529+ 'bushel' => array( 0.03636872, 'bsh|bushels?|impbsh', false ),
 530+ 'gallon' => array( 0.00454609, 'gal|gallons?|impgal', false ),
 531+ 'quart' => array( 0.0011365225, 'qt|quarts?|impqt', false ),
 532+ 'pint' => array( 0.00056826125, 'pt|pints?|imppt', false ),
 533+ 'fluidounce' => array( 0.0000284130625, 'floz|impfloz', false ),
549534
550 - 'barrelus' => array( 0.119240471196, 'usbbl' ),
551 - 'barreloil' => array( 0.158987294928, 'oilbbl' ),
552 - 'barrelbeer' => array( 0.117347765304, 'beerbbl' ),
553 - 'usgallon' => array( 0.003785411784, 'usgal' ),
554 - 'usquart' => array( 0.000946352946, 'usqt' ),
555 - 'uspint' => array( 0.000473176473, 'uspt' ),
556 - 'usfluidounce' => array( 0.0000295735295625, 'usfloz' ),
557 - 'usdrybarrel' => array( 0.11562819898508, 'usdrybbl' ),
558 - 'usbushel' => array( 0.03523907016688, 'usbsh' ),
559 - 'usdrygallon' => array( 0.00440488377086, 'usdrygal' ),
560 - 'usdryquart' => array( 0.001101220942715, 'usdryqt' ),
561 - 'usdrypint' => array( 0.0005506104713575, 'usdrypt' ),
 535+ 'barrelus' => array( 0.119240471196, 'usbbl', false ),
 536+ 'barreloil' => array( 0.158987294928, 'oilbbl', false ),
 537+ 'barrelbeer' => array( 0.117347765304, 'beerbbl', false ),
 538+ 'usgallon' => array( 0.003785411784, 'usgal', false ),
 539+ 'usquart' => array( 0.000946352946, 'usqt', false ),
 540+ 'uspint' => array( 0.000473176473, 'uspt', false ),
 541+ 'usfluidounce' => array( 0.0000295735295625, 'usfloz', false ),
 542+ 'usdrybarrel' => array( 0.11562819898508, 'usdrybbl', false ),
 543+ 'usbushel' => array( 0.03523907016688, 'usbsh', false ),
 544+ 'usdrygallon' => array( 0.00440488377086, 'usdrygal', false ),
 545+ 'usdryquart' => array( 0.001101220942715, 'usdryqt', false ),
 546+ 'usdrypint' => array( 0.0005506104713575, 'usdrypt', false ),
562547 ),
563548
564549 ConvertDimension::DIM_TIME => array(
565 - 'year' => array( 31557600, 'yr' ),
566 - 'day' => array( 86400, 'days?' ),
567 - 'hour' => array( 3600, 'hours?|hr|h' ),
568 - 'minute' => array( 60, 'minutes?|mins?' ),
569 - 'second' => array( 1, 's' ),
 550+ 'year' => array( 31557600, 'yr', true ),
 551+ 'day' => array( 86400, 'd|days?', false ),
 552+ 'hour' => array( 3600, 'hours?|hr|h', false ),
 553+ 'minute' => array( 60, 'minutes?|mins?', false ),
 554+ 'second' => array( 1, 's', false ),
570555 ),
571556
572557 ConvertDimension::DIM_SPEED => array(
573 - 'knot' => array( 0.514444444, 'knot|kn' ),
574 - 'speedoflight' => array( 2.9979E8, 'c' ),
 558+ 'knot' => array( 0.514444444, 'knot|kn', false ),
 559+ 'speedoflight' => array( 2.9979E8, 'c', false ),
575560 ),
576561
577562 ConvertDimension::DIM_PRESSURE => array(
578 - 'gigapascal' => array( 1000000000, 'GPa' ),
579 - 'megapascal' => array( 1000000, 'MPa' ), # Case-sensitivity is forced
580 - 'kilopascal' => array( 1000, 'kPa' ),
581 - 'hectopascal' => array( 100, 'hPa' ),
582 - 'pascal' => array( 1, 'Pa' ),
583 - 'millipascal' => array( 0.001, 'mPa' ), # Case-sensitivity is forced
 563+ 'pascal' => array( 1, 'Pa', true ),
584564
585 - 'bar' => array( 100000, 'bar' ),
586 - 'decibar' => array( 10000, 'dbar' ),
587 - 'milibar' => array( 100 , 'mbar|mb' ),
588 - 'kilobarye' => array( 100, 'kba' ),
589 - 'barye' => array( 0.1, 'ba' ),
 565+ 'bar' => array( 100000, 'bar', false ),
 566+ 'decibar' => array( 10000, 'dbar', false ),
 567+ 'milibar' => array( 100 , 'mbar|mb', false ),
 568+ 'kilobarye' => array( 100, 'kba', false ),
 569+ 'barye' => array( 0.1, 'ba', false ),
590570
591 - 'atmosphere' => array( 101325, 'atm|atmospheres?' ),
592 - 'torr' => array( 133.32237, 'torr' ),
593 - 'mmhg' => array( 133.322387415, 'mmHg' ),
594 - 'inhg' => array( 3386.38864034, 'inHg' ),
595 - 'psi' => array( 6894.757293, 'psi' ),
 571+ 'atmosphere' => array( 101325, 'atm|atmospheres?', false ),
 572+ 'torr' => array( 133.32237, 'torr', false ),
 573+ 'mmhg' => array( 133.322387415, 'mmHg', false ),
 574+ 'inhg' => array( 3386.38864034, 'inHg', false ),
 575+ 'psi' => array( 6894.757293, 'psi', false ),
596576 ),
597577 # TODO: other dimensions as needed
598578 );
599579
 580+ /**
 581+ * array(
 582+ * PREFIX => array(
 583+ * CONVERSION,
 584+ * REGEX,
 585+ * )
 586+ * )
 587+ * They're out of order because this is the order in which they are tested, and
 588+ * some prefixes are much more likely to occur than others
 589+ */
 590+ protected static $prefixes = array(
 591+ 'kilo' => array( 1E3, 'k' ),
 592+ 'mili' => array( 1E-3, 'm' ),
 593+ 'centi' => array( 1E-2, 'c' ),
 594+ 'giga' => array( 1E9, 'G' ),
 595+ 'micro' => array( 1E-6, '(?:\x{03BC}|\x{00B5})' ), # There are two similar mu characters
 596+ 'mega' => array( 1E6, 'M' ),
 597+ 'nano' => array( 1E-9, 'n' ),
 598+ 'hecto' => array( 1E2, 'h' ),
 599+ 'deca' => array( 1E1, 'da' ),
 600+ 'deci' => array( 1E-1, 'd' ),
 601+ 'yotta' => array( 1E24, 'Y' ),
 602+ 'zetta' => array( 1E21, 'Z' ),
 603+ 'exa' => array( 1E18, 'E' ),
 604+ 'peta' => array( 1E15, 'P' ),
 605+ 'tera' => array( 1E12, 'T' ),
 606+ 'pico' => array( 1E-12, 'p' ),
 607+ 'femto' => array( 1E-15, 'f' ),
 608+ 'atto' => array( 1E-18, 'a' ),
 609+ 'zepto' => array( 1E-21, 'z' ),
 610+ 'yocto' => array( 1E-24, 'y' ),
 611+ );
 612+
600613 # Default units for each dimension
601614 # TODO: this should ideally be localisable
602615 protected static $defaultUnit = array(
@@ -630,6 +643,9 @@
631644 # The name of the unit (key into $units[$dimension] above
632645 protected $unitName;
633646
 647+ # The SI prefix, if applicable
 648+ protected $prefix = null;
 649+
634650 /***************** MEMBER FUNCTIONS *****************/
635651
636652 /**
@@ -664,11 +680,25 @@
665681 # Single unit
666682 foreach( self::$units as $dimension => $units ){
667683 foreach( $units as $unit => $data ){
668 - if( $rawUnit == $unit || preg_match( "/^({$data[1]})$/u", $parts[0] ) ){
 684+ if( $rawUnit == $unit
 685+ || ( !$data[2] && preg_match( "/^({$data[1]})$/u", $parts[0] ) )
 686+ || ( $data[2] && preg_match( "/^(" . ConvertParser::PREFIX_REGEX . ")(" . $data[1] . ")$/u", $parts[0] ) ) )
 687+ {
669688 $this->dimension = new ConvertDimension( self::$dimensionMap[$unit] );
670 - $this->conversion = self::$units[$this->dimension->value][$unit][0];
 689+ $this->conversion = $data[0];
671690 $this->regex = $data[1];
672691 $this->unitName = $unit;
 692+
 693+ # Grab the SI prefix, if it's allowed and there is one
 694+ if( $data[2] && !preg_match( "/^({$data[1]})$/u", $parts[0] ) ){
 695+ foreach( self::$prefixes as $prefix => $pdata ){
 696+ if( preg_match( "/^({$pdata[1]})({$data[1]})$/u", $parts[0] ) ){
 697+ $this->prefix = $prefix;
 698+ break;
 699+ }
 700+ }
 701+ }
 702+
673703 return;
674704 }
675705 }
@@ -685,6 +715,7 @@
686716 $this->conversion = $top->conversion / $bottom->conversion;
687717 $this->regex = "(?:{$top->regex})/(?:{$bottom->regex})";
688718 $this->unitName = array( $top->unitName, $bottom->unitName );
 719+ $this->prefix = array( $top->prefix, $bottom->prefix );
689720 return;
690721
691722 } else {
@@ -694,7 +725,9 @@
695726 }
696727
697728 public function getConversion(){
698 - return $this->conversion;
 729+ return $this->prefix
 730+ ? $this->conversion * self::$prefixes[$this->prefix][0]
 731+ : $this->conversion;
699732 }
700733
701734 public function getRegex(){
@@ -714,7 +747,9 @@
715748
716749 if( !is_array( $this->unitName ) ){
717750 $msgText = $this->getTextFromMessage(
718 - "pfunc-convert-unit-{$this->dimension->getName()}-{$this->unitName}",
 751+ $this->dimension->getName(),
 752+ $this->unitName,
 753+ $this->prefix,
719754 $value, $link, $abbreviate, $language
720755 );
721756
@@ -723,18 +758,24 @@
724759 # so they can have it display "<metres per second>" rather than
725760 # "<metres>/<second>"
726761 $msgText = $this->getTextFromMessage(
727 - "pfunc-convert-unit-{$this->dimension->getName(true)}-{$this->unitName[0]}-{$this->unitName[1]}",
 762+ $this->dimension->getName(true),
 763+ "{$this->unitName[0]}-{$this->unitName[1]}",
 764+ $this->prefix, # This will probably be rubbish, but it's the wiki users' problem, not ours
728765 $value, $link, $abbreviate, $language
729766 );
730767
731768 } else {
732769 $dimensionNames = $this->dimension->getName();
733770 $msgText = $this->getTextFromMessage(
734 - "pfunc-convert-unit-{$dimensionNames[0]}-{$this->unitName[0]}",
 771+ $dimensionNames[0],
 772+ $this->unitName[0],
 773+ $this->prefix[0],
735774 $value, $link, $abbreviate, $language
736775 );
737776 $msg2Text = $this->getTextFromMessage(
738 - "pfunc-convert-unit-{$dimensionNames[1]}-{$this->unitName[1]}",
 777+ $dimensionNames[1],
 778+ $this->unitName[1],
 779+ $this->prefix[1],
739780 1, # Singular for denominator
740781 $link, $abbreviate, $language
741782 );
@@ -744,17 +785,24 @@
745786 return trim( $msgText );
746787 }
747788
748 - protected function getTextFromMessage( $key, $number, $link, $abbreviate, $language ){
 789+ protected function getTextFromMessage( $dimension, $unit, $prefix, $number, $link, $abbreviate, $language ){
749790 $abbr = $abbreviate ? '-abbr' : '';
 791+ $prefix = $prefix === null
 792+ ? ''
 793+ : wfMsgExt( "pfunc-convert-prefix-$prefix$abbr", array( 'parsemag', 'language' => $language ) );
750794
751795 $text = wfMsgExt(
752 - "$key$abbr",
 796+ "pfunc-convert-unit-$dimension-$unit$abbr",
753797 array( 'parsemag', 'language' => $language ),
754 - $number
 798+ $number,
 799+ $prefix
755800 );
756801
757 - if( $link && !wfEmptyMsg( "$key-link" ) ){
758 - $title = Title::newFromText( wfMsgForContentNoTrans( "$key-link" ) );
 802+ if( $link && !wfEmptyMsg( "pfunc-convert-unit-$dimension-$unit-link" ) ){
 803+ $title = Title::newFromText(
 804+ wfMsgForContentNoTrans( "pfunc-convert-unit-$dimension-$unit-link" ),
 805+ $prefix
 806+ );
759807 if( $title instanceof Title ){
760808 $text = "[[{$title->getFullText()}|$text]]";
761809 }
Index: trunk/extensions/ParserFunctions/ParserFunctions.i18n.php
@@ -54,18 +54,52 @@
5555 'pfunc-convert-dimension-fuelefficiencypositive' => 'fuelefficiencypositive',
5656 'pfunc-convert-dimension-fuelefficiencynegative' => 'fuelefficiencynegative',
5757
 58+ # SI PREFIXES
 59+
 60+ 'pfunc-convert-prefix-yotta' => 'yotta',
 61+ 'pfunc-convert-prefix-zetta' => 'zetta',
 62+ 'pfunc-convert-prefix-exa' => 'exa',
 63+ 'pfunc-convert-prefix-peta' => 'peta',
 64+ 'pfunc-convert-prefix-tera' => 'tera',
 65+ 'pfunc-convert-prefix-giga' => 'giga',
 66+ 'pfunc-convert-prefix-mega' => 'mega',
 67+ 'pfunc-convert-prefix-kilo' => 'kilo',
 68+ 'pfunc-convert-prefix-hecto' => 'hecto',
 69+ 'pfunc-convert-prefix-deca' => 'deca',
 70+ 'pfunc-convert-prefix-deci' => 'deci',
 71+ 'pfunc-convert-prefix-centi' => 'centi',
 72+ 'pfunc-convert-prefix-mili' => 'mili',
 73+ 'pfunc-convert-prefix-micro' => 'micro',
 74+ 'pfunc-convert-prefix-nano' => 'nano',
 75+ 'pfunc-convert-prefix-pico' => 'pico',
 76+ 'pfunc-convert-prefix-femto' => 'femto',
 77+ 'pfunc-convert-prefix-atto' => 'atto',
 78+ 'pfunc-convert-prefix-zepto' => 'zepto',
 79+ 'pfunc-convert-prefix-yocto' => 'yocto',
 80+
 81+ 'pfunc-convert-prefix-yotta-abbr' => 'Y',
 82+ 'pfunc-convert-prefix-zetta-abbr' => 'Z',
 83+ 'pfunc-convert-prefix-exa-abbr' => 'E',
 84+ 'pfunc-convert-prefix-peta-abbr' => 'P',
 85+ 'pfunc-convert-prefix-tera-abbr' => 'T',
 86+ 'pfunc-convert-prefix-giga-abbr' => 'G',
 87+ 'pfunc-convert-prefix-mega-abbr' => 'M',
 88+ 'pfunc-convert-prefix-kilo-abbr' => 'k',
 89+ 'pfunc-convert-prefix-hecto-abbr' => 'h',
 90+ 'pfunc-convert-prefix-deca-abbr' => 'da',
 91+ 'pfunc-convert-prefix-deci-abbr' => 'd',
 92+ 'pfunc-convert-prefix-centi-abbr' => 'c',
 93+ 'pfunc-convert-prefix-mili-abbr' => 'm',
 94+ 'pfunc-convert-prefix-micro-abbr' => 'μ',
 95+ 'pfunc-convert-prefix-nano-abbr' => 'n',
 96+ 'pfunc-convert-prefix-pico-abbr' => 'p',
 97+ 'pfunc-convert-prefix-femto-abbr' => 'f',
 98+ 'pfunc-convert-prefix-atto-abbr' => 'a',
 99+ 'pfunc-convert-prefix-zepto-abbr' => 'z',
 100+ 'pfunc-convert-prefix-yocto-abbr' => 'y',
 101+
58102 # LENGTH
59 - 'pfunc-convert-unit-length-gigametre' => '{{PLURAL:$1|gigameter|gigameters}}',
60 - 'pfunc-convert-unit-length-megametre' => '{{PLURAL:$1|megameter|megameters}}',
61 - 'pfunc-convert-unit-length-kilometre' => '{{PLURAL:$1|kilometer|kilometers}}',
62 - 'pfunc-convert-unit-length-hectometre' => '{{PLURAL:$1|hectometer|hectometers}}',
63 - 'pfunc-convert-unit-length-decametre' => '{{PLURAL:$1|decameter|decameters}}',
64 - 'pfunc-convert-unit-length-metre' => '{{PLURAL:$1|meter|meters}}',
65 - 'pfunc-convert-unit-length-decimetre' => '{{PLURAL:$1|decimeter|decimeters}}',
66 - 'pfunc-convert-unit-length-centimetre' => '{{PLURAL:$1|centimeter|centimeters}}',
67 - 'pfunc-convert-unit-length-millimetre' => '{{PLURAL:$1|millimeter|millimeters}}',
68 - 'pfunc-convert-unit-length-micrometre' => '{{PLURAL:$1|micrometer|micrometers}}',
69 - 'pfunc-convert-unit-length-nanometre' => '{{PLURAL:$1|nanometer|nanometers}}',
 103+ 'pfunc-convert-unit-length-metre' => '{{PLURAL:$1|$2meter|$2meters}}',
70104 'pfunc-convert-unit-length-angstrom' => '{{PLURAL:$1|angstrom|angstroms}}',
71105 'pfunc-convert-unit-length-mile' => '{{PLURAL:$1|mile|miles}}',
72106 'pfunc-convert-unit-length-furlong' => '{{PLURAL:$1|furlong|furlongs}}',
@@ -79,27 +113,11 @@
80114 'pfunc-convert-unit-length-nauticalmile' => '{{PLURAL:$1|nautical mile|nautical miles}}',
81115 'pfunc-convert-unit-length-nauticalmileuk' => '{{PLURAL:$1|nautical mile (pre-1970 British)|nautical miles (pre-1970 British)}}',
82116 'pfunc-convert-unit-length-nauticalmileus' => '{{PLURAL:$1|nautical mile (pre-1954 US)|nautical miles (pre-1954 US)}}',
83 - 'pfunc-convert-unit-length-gigaparsec' => '{{PLURAL:$1|gigaparsec|gigaparsecs}}',
84 - 'pfunc-convert-unit-length-megaparsec' => '{{PLURAL:$1|megaparsec|megaparsecs}}',
85 - 'pfunc-convert-unit-length-kiloparsec' => '{{PLURAL:$1|kiloparsec|kiloparsecs}}',
86 - 'pfunc-convert-unit-length-parsec' => '{{PLURAL:$1|parsec|parsecs}}',
87 - 'pfunc-convert-unit-length-gigalightyear' => '{{PLURAL:$1|gigalightyear|gigalightyears}}',
88 - 'pfunc-convert-unit-length-mrgalightyear' => '{{PLURAL:$1|megalightyear|megalightyears}}',
89 - 'pfunc-convert-unit-length-kilolightyear' => '{{PLURAL:$1|kilolightyear|kilolightyears}}',
90 - 'pfunc-convert-unit-length-lightyear' => '{{PLURAL:$1|lightyear|lightyears}}',
 117+ 'pfunc-convert-unit-length-parsec' => '{{PLURAL:$1|$2parsec|$2parsecs}}',
 118+ 'pfunc-convert-unit-length-lightyear' => '{{PLURAL:$1|$2lightyear|$2lightyears}}',
91119 'pfunc-convert-unit-length-astronomicalunit' => '{{PLURAL:$1|astronomical unit|astronomical units}}',
92120
93 - 'pfunc-convert-unit-length-gigametre-abbr' => 'Gm',
94 - 'pfunc-convert-unit-length-megametre-abbr' => 'Mm',
95 - 'pfunc-convert-unit-length-kilometre-abbr' => 'km',
96 - 'pfunc-convert-unit-length-hectometre-abbr' => 'hm',
97 - 'pfunc-convert-unit-length-decametre-abbr' => 'dam',
98 - 'pfunc-convert-unit-length-metre-abbr' => 'm',
99 - 'pfunc-convert-unit-length-decimetre-abbr' => 'dm',
100 - 'pfunc-convert-unit-length-centimetre-abbr' => 'cm',
101 - 'pfunc-convert-unit-length-milimetre-abbr' => 'mm',
102 - 'pfunc-convert-unit-length-micrometre-abbr' => 'μm',
103 - 'pfunc-convert-unit-length-nanometre-abbr' => 'nm',
 121+ 'pfunc-convert-unit-length-metre-abbr' => '$2m',
104122 'pfunc-convert-unit-length-angstrom-abbr' => 'Å',
105123 'pfunc-convert-unit-length-mile-abbr' => 'mi',
106124 'pfunc-convert-unit-length-furlong-abbr' => 'furlong',
@@ -113,14 +131,8 @@
114132 'pfunc-convert-unit-length-nauticalmile-abbr' => 'nmi',
115133 'pfunc-convert-unit-length-nauticalmileuk-abbr' => 'nmi (Brit)',
116134 'pfunc-convert-unit-length-nauticalmileus-abbr' => 'nmi (pre-1954 US)',
117 - 'pfunc-convert-unit-length-gigaparsec-abbr' => 'Gpc',
118 - 'pfunc-convert-unit-length-megaparsec-abbr' => 'Mpc',
119 - 'pfunc-convert-unit-length-kiloparsec-abbr' => 'kpc',
120 - 'pfunc-convert-unit-length-parsec-abbr' => 'pc',
121 - 'pfunc-convert-unit-length-gigalightyear-abbr' => 'Gly',
122 - 'pfunc-convert-unit-length-mrgalightyear-abbr' => 'Mly',
123 - 'pfunc-convert-unit-length-kilolightyear-abbr' => 'kly',
124 - 'pfunc-convert-unit-length-lightyear-abbr' => 'ly',
 135+ 'pfunc-convert-unit-length-parsec-abbr' => '$2pc',
 136+ 'pfunc-convert-unit-length-lightyear-abbr' => '$2ly',
125137 'pfunc-convert-unit-length-astronomicalunit-abbr' => 'AU',
126138
127139 # AREA #
@@ -154,13 +166,13 @@
155167
156168 # TIME #
157169 'pfunc-convert-unit-time-second' => '{{PLURAL:$1|second|seconds}}',
158 - 'pfunc-convert-unit-time-year' => '{{PLURAL:$1|year|years}}',
 170+ 'pfunc-convert-unit-time-year' => '{{PLURAL:$1|$2year|$2years}}',
159171 'pfunc-convert-unit-time-day' => '{{PLURAL:$1|day|days}}',
160172 'pfunc-convert-unit-time-hour' => '{{PLURAL:$1|hour|hours}}',
161173 'pfunc-convert-unit-time-minute' => '{{PLURAL:$1|minute|minutes}}',
162174
163175 'pfunc-convert-unit-time-second-abbr' => 's',
164 - 'pfunc-convert-unit-time-year-abbr' => 'yr',
 176+ 'pfunc-convert-unit-time-year-abbr' => '$2yr',
165177 'pfunc-convert-unit-time-day-abbr' => 'day',
166178 'pfunc-convert-unit-time-hour-abbr' => 'hr',
167179 'pfunc-convert-unit-time-minute-abbr' => 'min',
@@ -198,10 +210,7 @@
199211 'pfunc-convert-unit-volume-cubicmetre-abbr' => 'm<sup>3</sup>',
200212 'pfunc-convert-unit-volume-cubiccentimetre-abbr' => 'cm<sup>3</sup>',
201213 'pfunc-convert-unit-volume-cubicmillimetre-abbr' => 'mm<sup>3</sup>',
202 - 'pfunc-convert-unit-volume-kilolitre-abbr' => 'kl',
203 - 'pfunc-convert-unit-volume-litre-abbr' => 'l',
204 - 'pfunc-convert-unit-volume-centilitre-abbr' => 'cl',
205 - 'pfunc-convert-unit-volume-millilitre-abbr' => 'ml',
 214+ 'pfunc-convert-unit-volume-litre-abbr' => '$2l',
206215 'pfunc-convert-unit-volume-cubicyard-abbr' => 'cu yd',
207216 'pfunc-convert-unit-volume-cubicfoot-abbr' => 'cu ft',
208217 'pfunc-convert-unit-volume-cubicinch-abbr' => 'cu in',
@@ -232,12 +241,7 @@
233242 'pfunc-convert-unit-speed-speedoflight-abbr' => 'c',
234243
235244 # PRESSURE
236 - 'pfunc-convert-unit-pressure-gigapascal' => '{{PLURAL:$1|gigapascal|gigapascals}}',
237 - 'pfunc-convert-unit-pressure-megapascal' => '{{PLURAL:$1|megapascal|megapascals}}',
238 - 'pfunc-convert-unit-pressure-kilopascal' => '{{PLURAL:$1|kilopascal|kilopascals}}',
239 - 'pfunc-convert-unit-pressure-hectopascal' => '{{PLURAL:$1|hectopascal|hectopascals}}',
240 - 'pfunc-convert-unit-pressure-pascal' => '{{PLURAL:$1|pascal|pascals}}',
241 - 'pfunc-convert-unit-pressure-millipascal' => '{{PLURAL:$1|millipascal|millipascals}}',
 245+ 'pfunc-convert-unit-pressure-pascal' => '{{PLURAL:$1|$2pascal|$2pascals}}',
242246 'pfunc-convert-unit-pressure-bar' => 'bar',
243247 'pfunc-convert-unit-pressure-decibar' => 'decibar',
244248 'pfunc-convert-unit-pressure-millibar' => 'millibar',
@@ -248,13 +252,8 @@
249253 'pfunc-convert-unit-pressure-mmhg' => '{{PLURAL:$1|milimeter of mercury|milimeters of mercury}}',
250254 'pfunc-convert-unit-pressure-inhg' => '{{PLURAL:$1|inch of mercury|inches of mercury}}',
251255 'pfunc-convert-unit-pressure-psi' => '{{PLURAL:$1|pound per square-inch|pounds per square-inch}}',
252 -
253 - 'pfunc-convert-unit-pressure-gigapascal-abbr' => 'GPa',
254 - 'pfunc-convert-unit-pressure-megapascal-abbr' => 'MPa',
255 - 'pfunc-convert-unit-pressure-kilopascal-abbr' => 'kPa',
256 - 'pfunc-convert-unit-pressure-hectopascal-abbr' => 'hPa',
257 - 'pfunc-convert-unit-pressure-pascal-abbr' => 'Pa',
258 - 'pfunc-convert-unit-pressure-millipascal-abbr' => 'mPa',
 256+
 257+ 'pfunc-convert-unit-pressure-pascal-abbr' => '$2Pa',
259258 'pfunc-convert-unit-pressure-bar-abbr' => 'bar',
260259 'pfunc-convert-unit-pressure-decibar-abbr' => 'dbar',
261260 'pfunc-convert-unit-pressure-milibar-abbr' => 'mbar',
@@ -817,17 +816,7 @@
818817 */
819818 $messages['en-gb'] = array(
820819 # LENGTH
821 - 'pfunc-convert-unit-length-gigametre' => '{{PLURAL:$1|gigametre|gigametres}}',
822 - 'pfunc-convert-unit-length-megametre' => '{{PLURAL:$1|megametre|megametres}}',
823 - 'pfunc-convert-unit-length-kilometre' => '{{PLURAL:$1|kilometre|kilometres}}',
824 - 'pfunc-convert-unit-length-hectometre' => '{{PLURAL:$1|hectometre|hectometres}}',
825 - 'pfunc-convert-unit-length-decametre' => '{{PLURAL:$1|decametre|decametres}}',
826 - 'pfunc-convert-unit-length-metre' => '{{PLURAL:$1|metre|metres}}',
827 - 'pfunc-convert-unit-length-decimetre' => '{{PLURAL:$1|decimetre|decimetres}}',
828 - 'pfunc-convert-unit-length-centimetre' => '{{PLURAL:$1|centimetre|centimetres}}',
829 - 'pfunc-convert-unit-length-millimetre' => '{{PLURAL:$1|millimetre|millimetres}}',
830 - 'pfunc-convert-unit-length-micrometre' => '{{PLURAL:$1|micrometre|micrometres}}',
831 - 'pfunc-convert-unit-length-nanometre' => '{{PLURAL:$1|nanometre|nanometres}}',
 820+ 'pfunc-convert-unit-length-metre' => '{{PLURAL:$1|$2metre|$2metres}}',
832821
833822 # AREA #
834823 'pfunc-convert-unit-area-squarekilometre' => '{{PLURAL:$1|square kilometre|square kilometres}}',
@@ -839,10 +828,7 @@
840829 'pfunc-convert-unit-volume-cubicmetre' => '{{PLURAL:$1|cubic metre|cubic metres}}',
841830 'pfunc-convert-unit-volume-cubiccentimetre' => '{{PLURAL:$1|cubic centimetre|cubic centimetres}}',
842831 'pfunc-convert-unit-volume-cubicmillimetre' => '{{PLURAL:$1|cubic millimetre|cubic millimetres}}',
843 - 'pfunc-convert-unit-volume-kilolitre' => '{{PLURAL:$1|kilolitre|kilolitres}}',
844 - 'pfunc-convert-unit-volume-litre' => '{{PLURAL:$1|litre|litres}}',
845 - 'pfunc-convert-unit-volume-centilitre' => '{{PLURAL:$1|centilitre|centilitres}}',
846 - 'pfunc-convert-unit-volume-millilitre' => '{{PLURAL:$1|millilitre|millilitres}}',
 832+ 'pfunc-convert-unit-volume-litre' => '{{PLURAL:$1|$2litre|$2litres}}',
847833
848834 # PRESSURE
849835 'pfunc-convert-unit-pressure-mmhg' => '{{PLURAL:$1|milimetre of mercury|milimetres of mercury}}',

Follow-up revisions

RevisionCommit summaryAuthorDate
r82238Ignore messages in r82230 for now until this new feature is stabilizedraymond13:11, 16 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81074(bug 235) parser function for conversion of units of measurement....happy-melon00:13, 27 January 2011
r81517Follow-up r81074: turns out {{convert}} is (mostly) case-sensitive after all,...happy-melon14:28, 4 February 2011

Status & tagging log