Merge "Function for "pretty timestamps" that are human readable and understandable."
[lhc/web/wiklou.git] / languages / Language.php
index dfa8e2c..89f8bb7 100644 (file)
@@ -54,6 +54,7 @@ class FakeConverter {
        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 getPreferredVariant() { return $this->mLang->getCode(); }
        function getDefaultVariant() { return $this->mLang->getCode(); }
@@ -360,7 +361,7 @@ class Language {
         * @deprecated in 1.19
         */
        function getFallbackLanguageCode() {
-               wfDeprecated( __METHOD__ );
+               wfDeprecated( __METHOD__, '1.19' );
                return self::getFallbackFor( $this->mCode );
        }
 
@@ -423,6 +424,16 @@ class Language {
         */
        public function setNamespaces( array $namespaces ) {
                $this->namespaceNames = $namespaces;
+               $this->mNamespaceIds = null;
+       }
+
+       /**
+        * Resets all of the namespace caches. Mainly used for testing
+        */
+       public function resetNamespaces( ) {
+               $this->namespaceNames = null;
+               $this->mNamespaceIds = null;
+               $this->namespaceAliases = null;
        }
 
        /**
@@ -3677,6 +3688,16 @@ class Language {
                return $this->mConverter->convertTitle( $title );
        }
 
+       /**
+        * Convert a namespace index to a string in the preferred variant
+        *
+        * @param $ns int
+        * @return string
+        */
+       public function convertNamespace( $ns ) {
+               return $this->mConverter->convertNamespace( $ns );
+       }
+
        /**
         * Check if this is a language with variants
         *