Merge "Rephrase watchlistedit-clear-title"
[lhc/web/wiklou.git] / languages / classes / LanguageZh_hans.php
index d95c42e..77a41e1 100644 (file)
@@ -26,8 +26,9 @@
  *
  * @ingroup Language
  */
+// @codingStandardsIgnoreStart Ignore class name is not in camel caps format error
 class LanguageZh_hans extends Language {
-
+       // @codingStandardsIgnoreEnd
        /**
         * @return bool
         */
@@ -40,7 +41,7 @@ class LanguageZh_hans extends Language {
         * for now just treat each character as a word.
         * @todo FIXME: Only do this for Han characters...
         *
-        * @param $string string
+        * @param string $string
         *
         * @return string
         */
@@ -51,18 +52,45 @@ class LanguageZh_hans extends Language {
        }
 
        /**
-        * @param $s
+        * @param string $s
         * @return string
         */
        function normalizeForSearch( $s ) {
-               wfProfileIn( __METHOD__ );
 
                // Double-width roman characters
                $s = parent::normalizeForSearch( $s );
                $s = trim( $s );
                $s = $this->segmentByWord( $s );
 
-               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 int $seconds The amount of seconds.
+        * @param array $chosenIntervals The intervals to enable.
+        *
+        * @return string
+        */
+       public function formatDuration( $seconds, array $chosenIntervals = [] ) {
+               if ( empty( $chosenIntervals ) ) {
+                       $chosenIntervals = [ 'centuries', 'years', 'days', 'hours', 'minutes', 'seconds' ];
+               }
+
+               $intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
+
+               $segments = [];
+
+               foreach ( $intervals as $intervalName => $intervalValue ) {
+                       // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
+                       // duration-years, duration-decades, duration-centuries, duration-millennia
+                       $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue );
+                       $segments[] = $message->inLanguage( $this )->escaped();
+               }
+
+               return implode( '', $segments );
+       }
 }