MediaWiki  1.34.0
LanguageZh_hans.php
Go to the documentation of this file.
1 <?php
29 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
30 class LanguageZh_hans extends Language {
34  function hasWordBreaks() {
35  return false;
36  }
37 
47  function segmentByWord( $string ) {
48  $reg = "/([\\xc0-\\xff][\\x80-\\xbf]*)/";
49  $s = self::insertSpace( $string, $reg );
50  return $s;
51  }
52 
57  function normalizeForSearch( $s ) {
58  // Double-width roman characters
59  $s = parent::normalizeForSearch( $s );
60  $s = trim( $s );
61  $s = $this->segmentByWord( $s );
62 
63  return $s;
64  }
65 
76  public function formatDuration( $seconds, array $chosenIntervals = [] ) {
77  if ( empty( $chosenIntervals ) ) {
78  $chosenIntervals = [ 'centuries', 'years', 'days', 'hours', 'minutes', 'seconds' ];
79  }
80 
81  $intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
82 
83  $segments = [];
84 
85  foreach ( $intervals as $intervalName => $intervalValue ) {
86  // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
87  // duration-years, duration-decades, duration-centuries, duration-millennia
88  $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue );
89  $segments[] = $message->inLanguage( $this )->escaped();
90  }
91 
92  return implode( '', $segments );
93  }
94 }
LanguageZh_hans\hasWordBreaks
hasWordBreaks()
Definition: LanguageZh_hans.php:34
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
$s
$s
Definition: mergeMessageFileList.php:185
LanguageZh_hans\normalizeForSearch
normalizeForSearch( $s)
Definition: LanguageZh_hans.php:57
Language\getDurationIntervals
getDurationIntervals( $seconds, array $chosenIntervals=[])
Takes a number of seconds and returns an array with a set of corresponding intervals.
Definition: Language.php:2283
LanguageZh_hans
Simplified Chinese.
Definition: LanguageZh_hans.php:30
LanguageZh_hans\formatDuration
formatDuration( $seconds, array $chosenIntervals=[])
Takes a number of seconds and turns it into a text using values such as hours and minutes.
Definition: LanguageZh_hans.php:76
Language\insertSpace
static insertSpace( $string, $pattern)
Definition: Language.php:2859
Language
Internationalisation code.
Definition: Language.php:37
LanguageZh_hans\segmentByWord
segmentByWord( $string)
Eventually this should be a word segmentation; for now just treat each character as a word.
Definition: LanguageZh_hans.php:47