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