MediaWiki REL1_41
LanguageZh_hans.php
Go to the documentation of this file.
1<?php
20// phpcs:ignoreFile Squiz.Classes.ValidClassName.NotCamelCaps
21
28 public function hasWordBreaks() {
29 return false;
30 }
31
37 public function segmentByWord( $string ) {
38 $reg = "/([\\xc0-\\xff][\\x80-\\xbf]*)/";
39 return self::insertSpace( $string, $reg );
40 }
41
42 public function normalizeForSearch( $s ) {
43 // Double-width roman characters
44 $s = parent::normalizeForSearch( $s );
45 $s = trim( $s );
46 return $this->segmentByWord( $s );
47 }
48
49 public function formatDuration( $seconds, array $chosenIntervals = [] ) {
50 if ( !$chosenIntervals ) {
51 $chosenIntervals = [ 'centuries', 'years', 'days', 'hours', 'minutes', 'seconds' ];
52 }
53
54 $intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
55
56 $segments = [];
57
58 foreach ( $intervals as $intervalName => $intervalValue ) {
59 // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
60 // duration-years, duration-decades, duration-centuries, duration-millennia
61 $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue );
62 $segments[] = $message->inLanguage( $this )->escaped();
63 }
64
65 return implode( '', $segments );
66 }
67}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Simplified Chinese.
hasWordBreaks()
Most writing systems use whitespace to break up words.
segmentByWord( $string)
formatDuration( $seconds, array $chosenIntervals=[])
Takes a number of seconds and turns it into a text using values such as hours and minutes.
normalizeForSearch( $s)
Some languages have special punctuation need to be normalized.
Base class for language-specific code.
Definition Language.php:63
static insertSpace( $string, $pattern)
getDurationIntervals( $seconds, array $chosenIntervals=[])
Takes a number of seconds and returns an array with a set of corresponding intervals.