Make FakeConverter more realistic
[lhc/web/wiklou.git] / languages / Language.php
index e5cab05..702d0b4 100644 (file)
@@ -49,12 +49,14 @@ class FakeConverter {
         */
        public $mLang;
        function __construct( $langobj ) { $this->mLang = $langobj; }
+       function autoConvert( $text, $variant = false ) { return $text; }
        function autoConvertToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); }
        function convert( $t ) { return $t; }
        function convertTo( $text, $variant ) { return $text; }
        function convertTitle( $t ) { return $t->getPrefixedText(); }
        function convertNamespace( $ns ) { return $this->mLang->getFormattedNsText( $ns ); }
        function getVariants() { return array( $this->mLang->getCode() ); }
+       function getVariantFallbacks( $variant ) { return $this->mLang->getCode(); }
        function getPreferredVariant() { return $this->mLang->getCode(); }
        function getDefaultVariant() { return $this->mLang->getCode(); }
        function getURLVariant() { return ''; }
@@ -66,6 +68,8 @@ class FakeConverter {
        function convertCategoryKey( $key ) { return $key; }
        function convertLinkToAllVariants( $text ) { return $this->autoConvertToAllVariants( $text ); }
        function armourMath( $text ) { return $text; }
+       function validateVariant( $variant = null ) { return $variant === $this->mLang->getCode() ? $variant : null; }
+       function translate( $text, $variant ) { return $text; }
 }
 
 /**
@@ -3616,7 +3620,7 @@ class Language {
        function convertPlural( $count, $forms ) {
                // Handle explicit n=pluralform cases
                foreach ( $forms as $index => $form ) {
-                       if ( preg_match( '/\d+=/i', $form ) ) {
+                       if ( preg_match( '/^\d+=/i', $form ) ) {
                                $pos = strpos( $form, '=' );
                                if ( substr( $form, 0, $pos ) === (string) $count ) {
                                        return substr( $form, $pos + 1 );