From e88b0fbeb3a07e621eedec0f4673da3dfe356935 Mon Sep 17 00:00:00 2001 From: Liangent Date: Wed, 5 Dec 2012 15:18:45 +0800 Subject: [PATCH] Add LanguageZh_hans::formatDuration() for Chinese. Change-Id: Idf308e82887fc1d964e08b28904e026d0b2e4217 --- languages/classes/LanguageZh_hans.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/languages/classes/LanguageZh_hans.php b/languages/classes/LanguageZh_hans.php index d95c42eacc..ea81afb3b4 100644 --- a/languages/classes/LanguageZh_hans.php +++ b/languages/classes/LanguageZh_hans.php @@ -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 ); + } } -- 2.20.1