MediaWiki master
LanguageZh_hans.php
Go to the documentation of this file.
1<?php
20// phpcs:ignoreFile Squiz.Classes.ValidClassName.NotCamelCaps
21
23
30
31 private const WORD_SEGMENTATION_REGEX = '/([\xc0-\xff][\x80-\xbf]*)/';
32
33 public function hasWordBreaks() {
34 return false;
35 }
36
42 public function segmentByWord( $string ) {
43 return self::insertSpace( $string, self::WORD_SEGMENTATION_REGEX );
44 }
45
46 public function normalizeForSearch( $s ) {
47 // Double-width roman characters
48 $s = parent::normalizeForSearch( $s );
49 $s = trim( $s );
50 return $this->segmentByWord( $s );
51 }
52
53 public function formatDuration( $seconds, array $chosenIntervals = [] ) {
54 if ( !$chosenIntervals ) {
55 $chosenIntervals = [ 'centuries', 'years', 'days', 'hours', 'minutes', 'seconds' ];
56 }
57
58 $intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
59
60 $segments = [];
61
62 foreach ( $intervals as $intervalName => $intervalValue ) {
63 // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
64 // duration-years, duration-decades, duration-centuries, duration-millennia
65 $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue );
66 $segments[] = $message->inLanguage( $this )->escaped();
67 }
68
69 return implode( '', $segments );
70 }
71}
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:80
static insertSpace( $string, $pattern)
getDurationIntervals( $seconds, array $chosenIntervals=[])
Takes a number of seconds and returns an array with a set of corresponding intervals.