Add LanguageZh_hans::formatDuration() for Chinese.
authorLiangent <liangent@gmail.com>
Wed, 5 Dec 2012 07:18:45 +0000 (15:18 +0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 22 Dec 2012 18:28:35 +0000 (18:28 +0000)
Change-Id: Idf308e82887fc1d964e08b28904e026d0b2e4217

languages/classes/LanguageZh_hans.php

index d95c42e..ea81afb 100644 (file)
@@ -65,4 +65,31 @@ class LanguageZh_hans extends Language {
                wfProfileOut( __METHOD__ );
                return $s;
        }
+
+       /**
+        * Takes a number of seconds and turns it into a text using values such as hours and minutes.
+        *
+        * @since 1.21
+        *
+        * @param integer $seconds The amount of seconds.
+        * @param array $chosenIntervals The intervals to enable.
+        *
+        * @return string
+        */
+       public function formatDuration( $seconds, array $chosenIntervals = array() ) {
+               if ( empty( $chosenIntervals ) ) {
+                       $chosenIntervals = array( 'centuries', 'years', 'days', 'hours', 'minutes', 'seconds' );
+               }
+
+               $intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
+
+               $segments = array();
+
+               foreach ( $intervals as $intervalName => $intervalValue ) {
+                       $message = new Message( 'duration-' . $intervalName, array( $intervalValue ) );
+                       $segments[] = $message->inLanguage( $this )->escaped();
+               }
+
+               return implode( '', $segments );
+       }
 }