Add RELEASE-NOTES-1.18.old into RELEASE-NOTES-1.18
[lhc/web/wiklou.git] / languages / LanguageConverter.php
index 730191e..ba89be7 100644 (file)
@@ -67,12 +67,12 @@ class LanguageConverter {
        public function __construct( $langobj, $maincode, $variants = array(),
                                                                $variantfallbacks = array(), $flags = array(),
                                                                $manualLevel = array() ) {
-               global $wgDisabledVariants, $wgLanguageNames;
+               global $wgDisabledVariants;
                $this->mLangObj = $langobj;
                $this->mMainLanguageCode = $maincode;
                $this->mVariants = array_diff( $variants, $wgDisabledVariants );
                $this->mVariantFallbacks = $variantfallbacks;
-               $this->mVariantNames = $wgLanguageNames;
+               $this->mVariantNames = Language::getLanguageNames();
                $this->mCacheKey = wfMemcKey( 'conversiontables', $maincode );
                $defaultflags = array(
                        // 'S' show converted text
@@ -305,9 +305,9 @@ class LanguageConverter {
         * If you want to parse rules, try to use convert() or
         * convertTo().
         *
-        * @param $text String: the text to be converted
-        * @param $toVariant String: the target language code
-        * @return String: the converted text
+        * @param $text String the text to be converted
+        * @param $toVariant bool|string the target language code
+        * @return String the converted text
         */
        public function autoConvert( $text, $toVariant = false ) {
                wfProfileIn( __METHOD__ );
@@ -468,7 +468,7 @@ class LanguageConverter {
         *
         * @param $text String: the text to be converted
         * @return Array: variant => converted text
-        * @deprecated Use autoConvertToAllVariants() instead
+        * @deprecated since 1.17 Use autoConvertToAllVariants() instead
         */
        public function convertLinkToAllVariants( $text ) {
                return $this->autoConvertToAllVariants( $text );
@@ -477,7 +477,7 @@ class LanguageConverter {
        /**
         * Apply manual conversion rules.
         *
-        * @param $convRule Object: Object of ConverterRule
+        * @param $convRule ConverterRule Object of ConverterRule
         */
        protected function applyManualConv( $convRule ) {
                // Use syntax -{T|zh-cn:TitleCN; zh-tw:TitleTw}- to custom
@@ -517,7 +517,7 @@ class LanguageConverter {
         * Auto convert a Title object to a readable string in the
         * preferred variant.
         *
-        * @param $title Object: a object of Title
+        * @param $title Title a object of Title
         * @return String: converted title text
         */
        public function convertTitle( $title ) {
@@ -527,9 +527,9 @@ class LanguageConverter {
                        $text = '';
                } else {
                        // first let's check if a message has given us a converted name
-                       $nsConvKey = 'conversion-ns' . $index;
-                       if ( !wfEmptyMsg( $nsConvKey ) ) {
-                               $text = wfMsgForContentNoTrans( $nsConvKey );
+                       $nsConvMsg = wfMessage( 'conversion-ns' . $index )->inContentLanguage();
+                       if ( $nsConvMsg->exists() ) {
+                               $text = $nsConvMsg->plain();
                        } else {
                                // the message does not exist, try retrieve it from the current
                                // variant's namespace names.
@@ -618,7 +618,9 @@ class LanguageConverter {
         *
         * @param $text String: text to be converted
         * @param $variant String: the target variant code
+        * @param $startPos int
         * @param $depth Integer: depth of recursion
+        *
         * @return String: converted text
         */
        protected function recursiveConvertRule( $text, $variant, &$startPos, $depth = 0 ) {
@@ -762,6 +764,8 @@ class LanguageConverter {
 
        /**
         * Returns language specific hash options.
+        *
+        * @return string
         */
        public function getExtraHashOptions() {
                $variant = $this->getPreferredVariant();
@@ -776,7 +780,7 @@ class LanguageConverter {
         */
        function loadDefaultTables() {
                $name = get_class( $this );
-               wfDie( "Must implement loadDefaultTables() method in class $name" );
+               throw new MWException( "Must implement loadDefaultTables() method in class $name" );
        }
 
        /**
@@ -852,6 +856,8 @@ class LanguageConverter {
         * @param $code String: language code
         * @param $subpage String: subpage name
         * @param $recursive Boolean: parse subpages recursively? Defaults to true.
+        *
+        * @return array
         */
        function parseCachedTable( $code, $subpage = '', $recursive = true ) {
                static $parsed = array();
@@ -867,7 +873,7 @@ class LanguageConverter {
                if ( strpos( $code, '/' ) === false ) {
                        $txt = MessageCache::singleton()->get( 'Conversiontable', true, $code );
                        if ( $txt === false ) {
-                               # FIXME: this method doesn't seem to be expecting
+                               # @todo FIXME: This method doesn't seem to be expecting
                                # this possible outcome...
                                $txt = '<Conversiontable>';
                        }
@@ -971,6 +977,10 @@ class LanguageConverter {
        /**
         * Convert the sorting key for category links. This should make different
         * keys that are variants of each other map to the same key.
+        *
+        * @param $key string
+        *
+        * @return string
         */
        function convertCategoryKey( $key ) {
                return $key;
@@ -981,7 +991,7 @@ class LanguageConverter {
         * MediaWiki:Conversiontable* is updated.
         * @private
         *
-        * @param $article Object: Article object
+        * @param $article Article object
         * @param $user Object: User object for the current user
         * @param $text String: article text (?)
         * @param $summary String: edit summary of the edit
@@ -1215,6 +1225,8 @@ class ConverterRule {
 
        /**
         * @private
+        *
+        * @return string
         */
        function getRulesDesc() {
                $codesep = $this->mConverter->mDescCodeSep;
@@ -1235,6 +1247,10 @@ class ConverterRule {
        /**
         * Parse rules conversion.
         * @private
+        *
+        * @param $variant
+        *
+        * @return string
         */
        function getRuleConvertedStr( $variant ) {
                $bidtable = $this->mBidtable;
@@ -1444,6 +1460,7 @@ class ConverterRule {
 
        /**
         * Get display text on markup -{...}-
+        * @return string
         */
        public function getDisplay() {
                return $this->mRuleDisplay;
@@ -1451,6 +1468,7 @@ class ConverterRule {
 
        /**
         * Get converted title.
+        * @return string
         */
        public function getTitle() {
                return $this->mRuleTitle;
@@ -1458,6 +1476,7 @@ class ConverterRule {
 
        /**
         * Return how deal with conversion rules.
+        * @return string
         */
        public function getRulesAction() {
                return $this->mRulesAction;
@@ -1466,6 +1485,7 @@ class ConverterRule {
        /**
         * Get conversion table. (bidirectional and unidirectional
         * conversion table)
+        * @return array
         */
        public function getConvTable() {
                return $this->mConvTable;
@@ -1473,6 +1493,7 @@ class ConverterRule {
 
        /**
         * Get conversion rules string.
+        * @return string
         */
        public function getRules() {
                return $this->mRules;
@@ -1480,6 +1501,7 @@ class ConverterRule {
 
        /**
         * Get conversion flags.
+        * @return array
         */
        public function getFlags() {
                return $this->mFlags;