Resolves bug #26131 by always placing user scripts and styles at the very end of...
[lhc/web/wiklou.git] / languages / Language.php
index 9a1a302..2829153 100644 (file)
@@ -52,7 +52,7 @@ class FakeConverter {
        function getParsedTitle() { return ''; }
        function markNoConversion( $text, $noParse = false ) { return $text; }
        function convertCategoryKey( $key ) { return $key; }
-       function convertLinkToAllVariants( $text ) { return autoConvertToAllVariants( $text ); }
+       function convertLinkToAllVariants( $text ) { return $this->autoConvertToAllVariants( $text ); }
        function armourMath( $text ) { return $text; }
 }
 
@@ -1545,11 +1545,11 @@ class Language {
        }
 
        function getMessage( $key ) {
-               return self::$dataCache->getSubitem( $this->mCode, 'messages', $key );
+               return self::$dataCache->getSubitem( $this->getCodeForMessage(), 'messages', $key );
        }
 
        function getAllMessages() {
-               return self::$dataCache->getItem( $this->mCode, 'messages' );
+               return self::$dataCache->getItem( $this->getCodeForMessage(), 'messages' );
        }
 
        function iconv( $in, $out, $string ) {
@@ -2706,6 +2706,8 @@ class Language {
         * If a language supports multiple variants, converts text
         * into an array of all possible variants of the text:
         *  'variant' => text in that variant
+        *
+        * @deprecated Use autoConvertToAllVariants()
         */
        function convertLinkToAllVariants( $text ) {
                return $this->mConverter->convertLinkToAllVariants( $text );
@@ -2764,6 +2766,18 @@ class Language {
        function getCode() {
                return $this->mCode;
        }
+       
+       /**
+        * Get langcode for message
+        * Some language, like Chinese (zh, without any suffix), has multiple
+        * interface languages, we could choose a better one for user.
+        * Inherit class can override this function if necessary.
+        *
+        * @return string
+        */
+       function getCodeForMessage() {
+               return $this->getPreferredVariant();
+       }
 
        function setCode( $code ) {
                $this->mCode = $code;
@@ -2873,11 +2887,11 @@ class Language {
        }
 
        function formatTimePeriod( $seconds ) {
-               if ( $seconds < 10 ) {
-                       return $this->formatNum( sprintf( "%.1f", $seconds ) ) . $this->getMessageFromDB( 'seconds-abbrev' );
-               } elseif ( $seconds < 60 ) {
+               if ( round( $seconds * 10 ) < 100 ) {
+                       return $this->formatNum( sprintf( "%.1f", round( $seconds * 10 ) / 10 ) ) . $this->getMessageFromDB( 'seconds-abbrev' );
+               } elseif ( round( $seconds ) < 60 ) {
                        return $this->formatNum( round( $seconds ) ) . $this->getMessageFromDB( 'seconds-abbrev' );
-               } elseif ( $seconds < 3600 ) {
+               } elseif ( round( $seconds ) < 3600 ) {
                        $minutes = floor( $seconds / 60 );
                        $secondsPart = round( fmod( $seconds, 60 ) );
                        if ( $secondsPart == 60 ) {