Localisation updates for core and extension messages from translatewiki.net (2010...
[lhc/web/wiklou.git] / languages / LanguageConverter.php
index 9e188ce..06f794d 100644 (file)
@@ -515,24 +515,6 @@ class LanguageConverter {
                }
        }
 
-       /**
-        * Convert namespace.
-        * @param $title String: the title included namespace
-        * @return Array of string
-        * @private
-        */
-       function convertNamespace( $title, $variant ) {
-               $splittitle = explode( ':', $title, 2 );
-               if ( count( $splittitle ) < 2 ) {
-                       return $title;
-               }
-               if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) ) {
-                       $splittitle[0] = $this->mNamespaceTables[$variant][$splittitle[0]];
-               }
-               $ret = implode( ':', $splittitle );
-               return $ret;
-       }
-
        /**
         * Convert text to different variants of a language. The automatic
         * conversion is done in autoConvert(). Here we parse the text
@@ -556,6 +538,25 @@ class LanguageConverter {
                return $this->recursiveConvertTopLevel( $text, $variant );
        }
 
+       /**
+        * Convert a Title object to a readable string in the preferred variant
+        */
+       public function convertTitle( $title ) {
+               $variant = $this->getPreferredVariant();
+               if ( $title->getNamespace() === NS_MAIN ) {
+                       $text = '';
+               } else {
+                       $text = $title->getNsText();
+                       if ( isset( $this->mNamespaceTables[$variant][$text] ) ) {
+                               $text = $this->mNamespaceTables[$variant][$text];
+                       }
+                       $text .= ':';
+               }
+               $text .= $title->getText();
+               $text = $this->autoConvert( $text, $variant );
+               return $text;
+       }
+
        protected function recursiveConvertTopLevel( $text, $variant, $depth = 0 ) {
                $startPos = 0;
                $out = '';