Show HTTP error (if any) when scary transclusion fails
[lhc/web/wiklou.git] / languages / Language.php
index e67c086..69a72eb 100644 (file)
@@ -800,7 +800,7 @@ class Language {
         * @return string
         */
        function getMessageFromDB( $msg ) {
-               return wfMsgExt( $msg, array( 'parsemag', 'language' => $this ) );
+               return wfMessage( $msg )->inLanguage( $this )->text();
        }
 
        /**
@@ -2865,7 +2865,7 @@ class Language {
          *
          * An example of this function being called:
          * <code>
-         * wfMsg( 'message', $wgLang->formatNum( $num ) )
+         * wfMessage( 'message' )->numParams( $num )->text()
          * </code>
          *
          * See LanguageGu.php for the Gujarati implementation and
@@ -3032,10 +3032,7 @@ class Language {
         */
        function commaList( array $list ) {
                return implode(
-                       wfMsgExt(
-                               'comma-separator',
-                               array( 'parsemag', 'escapenoentities', 'language' => $this )
-                       ),
+                       wfMessage( 'comma-separator' )->inLanguage( $this )->escaped(),
                        $list
                );
        }
@@ -3048,10 +3045,7 @@ class Language {
         */
        function semicolonList( array $list ) {
                return implode(
-                       wfMsgExt(
-                               'semicolon-separator',
-                               array( 'parsemag', 'escapenoentities', 'language' => $this )
-                       ),
+                       wfMessage( 'semicolon-separator' )->inLanguage( $this )->escaped(),
                        $list
                );
        }
@@ -3063,10 +3057,7 @@ class Language {
         */
        function pipeList( array $list ) {
                return implode(
-                       wfMsgExt(
-                               'pipe-separator',
-                               array( 'escapenoentities', 'language' => $this )
-                       ),
+                       wfMessage( 'pipe-separator' )->inLanguage( $this )->escaped(),
                        $list
                );
        }
@@ -3091,7 +3082,7 @@ class Language {
        function truncate( $string, $length, $ellipsis = '...', $adjustLength = true ) {
                # Use the localized ellipsis character
                if ( $ellipsis == '...' ) {
-                       $ellipsis = wfMsgExt( 'ellipsis', array( 'escapenoentities', 'language' => $this ) );
+                       $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this )->escaped();
                }
                # Check if there is no need to truncate
                if ( $length == 0 ) {
@@ -3189,7 +3180,7 @@ class Language {
        function truncateHtml( $text, $length, $ellipsis = '...' ) {
                # Use the localized ellipsis character
                if ( $ellipsis == '...' ) {
-                       $ellipsis = wfMsgExt( 'ellipsis', array( 'escapenoentities', 'language' => $this ) );
+                       $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this )->escaped();
                }
                # Check if there is clearly no need to truncate
                if ( $length <= 0 ) {
@@ -4116,7 +4107,7 @@ class Language {
                $dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) .
                        $this->getDirMark();
                $details = $details ? $dirmark . $this->getMessageFromDB( 'word-separator' ) .
-                       wfMsgExt( 'parentheses', array( 'escape', 'replaceafter', 'language' => $this ), $details ) : '';
+                       wfMessage( 'parentheses' )->rawParams( $details )->inLanguage( $this )->escaped() : '';
                return $page . $details;
        }
 
@@ -4190,6 +4181,15 @@ class Language {
                return $this->mConverter->getConvRuleTitle();
        }
 
+       /**
+        * Get the compiled plural rules for the language
+        * @since 1.20
+        * @return array Associative array with plural form, and plural rule as key-value pairs
+        */
+       public function getCompiledPluralRules() {
+               return self::$dataCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' );
+       }
+
        /**
         * Get the plural rules for the language
         * @since 1.20
@@ -4205,8 +4205,8 @@ class Language {
         * @return int The index of the plural form
         */
        private function getPluralForm( $number ) {
-               $pluralRules = $this->getPluralRules();
-               $form = CLDRPluralRuleEvaluator::evaluate( $number, $pluralRules );
+               $pluralRules = $this->getCompiledPluralRules();
+               $form = CLDRPluralRuleEvaluator::evaluateCompiled( $number, $pluralRules );
                return $form;
        }